External module function

In order to calculate magnetic moments
the following function has to be present in the module file **.so*:

extern "C" void mcalc(Vector & m,double * T, Vector & Hxc, Vector & Hext, double * gJ, Vector & MODPAR, char ** sipffilename, ComplexMatrix & Icalc_parstorage);

Note for windows users with MINGW the declaration
should be *extern "C" __declspec(dllexport) void mcalc(...)*.

The meaning of the symbols is as follows:

on input T temperature[K] Hxc vector of exchange field [meV] (n-dimensional, for a set of n operators I) Hext external magnetic field [T] (3 components) gJ Lande factor as read from sipf file MODPAR Vector with Parameters read from single ion property file sipffilename file name of the single ion parameter file Icalc_parstorage parameter matrix (initialized by Icalc_parameter_storage_matrix_init) it should/may contain any information, e.g. population numbers of the states (imaginary part of row 0) and eigenvalues (real part of row 0) with values set by the most recent call for this ion (use of this matrix is optional, it is provided to save time by storing here information instead of recalculating it for every call of Icalc) on output m =<2S+L>, thermal expectation value of the magnetic moment operator <m> in units of muB Icalc_parstorage parameter matrix matrix (optional) it should/may contain any information for the next call of mcalc/Icalc, e.g. population numbers of the states (imaginary part of row 0) and eigenvalues (real part of row 0) ...The module function must perform the following tasks:

- check if the dimensions of vector Hxc (taken by
*mcphas*from the number of interaction constant columns in*mcphas.j*) and MODPAR (taken by*mcphas*from the number of params in the single ion property file) agree with the module specifications. If the check fails the module function should exit the program with an appropriate error message - the module should calculate from external field at a given temperature the thermal expectation values of the three components of the magnetic moment and return them as a vector . Input file parameters params are supplied as a vector MODPAR and Lande factor as gJ and can be used for this purpose. The Hamiltonian is usually assumed to be of the general form .
- if all quantities should be evaluated assuming that all Boltzmann probabilities are zero except for the state number , for which the probability .

Thus the function resembles closely Icalc, however no U and lnZ are calculated and the magnetic moment vector m, which is returned, has always exactly 3 components.

Martin Rotter 2017-01-10