-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge branch 'master' into TwoYukawa
Showing
18 changed files
with
653 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
Copyright (c) 2009-2022, SasView Developers | ||
|
||
Copyright (c) 2009-2024, SasView Developers | ||
|
||
All rights reserved. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
//These functions are required for magnetic analysis models. They are copies | ||
//from sasmodels/kernel_iq.c, to enables magnetic parameters for 1D and 2D models. | ||
|
||
|
||
static double langevin( | ||
double x) { | ||
// cotanh(x)-1\x | ||
|
||
if (x < 0.00001) { | ||
// avoid dividing by zero | ||
return 1.0/3.0*x-1.0/45.0 * pow(x, 3) + 2.0/945.0 * pow(x, 5) - 1.0/4725.0 * pow(x, 7); | ||
} else { | ||
return 1.0/tanh(x)-1/x; | ||
} | ||
} | ||
|
||
static double langevinoverx( | ||
double x) | ||
{ | ||
// cotanh(x)-1\x | ||
|
||
if (x < 0.00001) { | ||
// avoid dividing by zero | ||
return 1.0/3.0-1.0/45.0 * pow(x, 2) + 2.0/945.0 * pow(x, 4) - 1.0/4725.0 * pow(x, 6); | ||
} else { | ||
return langevin(x)/x; | ||
} | ||
} | ||
|
||
|
||
|
||
//weighting of spin resolved cross sections to reconstruct partially polarised beam with imperfect optics using up_i/up_f. | ||
static void set_weights(double in_spin, double out_spin, double weight[8]) //from kernel_iq.c | ||
{ | ||
double norm=out_spin; | ||
|
||
|
||
in_spin = clip(sqrt(square(in_spin)), 0.0, 1.0);//opencl has ambiguities for abs() | ||
out_spin = clip(sqrt(square(out_spin)), 0.0, 1.0); | ||
|
||
if (out_spin < 0.5){norm=1-out_spin;} | ||
|
||
// The norm is needed to make sure that the scattering cross sections are | ||
//correctly weighted, such that the sum of spin-resolved measurements adds up to | ||
// the unpolarised or half-polarised scattering cross section. No intensity weighting | ||
// needed on the incoming polariser side assuming that a user has normalised | ||
// to the incoming flux with polariser in for SANSPOl and unpolarised beam, respectively. | ||
|
||
|
||
weight[0] = (1.0-in_spin) * (1.0-out_spin) / norm; // dd.real | ||
weight[1] = weight[0]; // dd.imag | ||
weight[2] = in_spin * out_spin / norm; // uu.real | ||
weight[3] = weight[2]; // uu.imag | ||
weight[4] = (1.0-in_spin) * out_spin / norm; // du.real | ||
weight[5] = weight[4]; // du.imag | ||
weight[6] = in_spin * (1.0-out_spin) / norm; // ud.real | ||
weight[7] = weight[6]; // ud.imag | ||
} | ||
|
||
|
||
|
||
//transforms scattering vector q in polarisation/magnetisation coordinate system | ||
static void set_scatvec(double *qrot, double q, | ||
double cos_theta, double sin_theta, | ||
double alpha, double beta) | ||
{ | ||
double cos_alpha, sin_alpha; | ||
double cos_beta, sin_beta; | ||
|
||
SINCOS(alpha*M_PI/180, sin_alpha, cos_alpha); | ||
SINCOS(beta*M_PI/180, sin_beta, cos_beta); | ||
//field is defined along (0,0,1), orientation of detector | ||
//is precessing in a cone around B with an inclination of theta | ||
|
||
qrot[0] = q*(cos_alpha * cos_theta); | ||
qrot[1] = q*(cos_theta * sin_alpha*sin_beta + | ||
cos_beta * sin_theta); | ||
qrot[2] = q*(-cos_beta * cos_theta* sin_alpha + | ||
sin_beta * sin_theta); | ||
} | ||
|
||
|
||
|
||
//Evaluating the magnetic scattering vector (Halpern Johnson vector) for general orientation of q and collecting terms for the spin-resolved (POLARIS) cross sections. Mz is along the applied magnetic field direction, which is also the polarisation direction. | ||
static void mag_sld( | ||
// 0=dd.real, 1=dd.imag, 2=uu.real, 3=uu.imag, 4=du.real, 5=du.imag, 6=ud.real, 7=ud.imag | ||
double qx, double qy, double qz, | ||
double mxreal, double mximag, double myreal, double myimag, double mzreal,double mzimag, double nuc, double sld[8]) | ||
{ | ||
double vector[3]; | ||
//The (transversal) magnetisation and hence the magnetic scattering sector is here a complex quantity. The spin-flip (magnetic) scattering amplitude is given with | ||
// MperpPperpQ \pm i MperpP (Moon-Riste-Koehler Phys Rev 181, 920, 1969) with Mperp and MperpPperpQ the | ||
//magnetisation scattering vector components perpendicular to the polarisation/field direction. Collecting terms in SF that are real (MperpPperpQreal + SCALAR_VEC(MperpPimag,qvector) ) and imaginary (MperpPperpQimag \pm SCALAR_VEC(MperpPreal,qvector) ) | ||
double Mvectorreal[3]; | ||
double Mvectorimag[3]; | ||
double Pvector[3]; | ||
double perpy[3]; | ||
double perpx[3]; | ||
|
||
double Mperpreal[3]; | ||
double Mperpimag[3]; | ||
|
||
const double q = sqrt(qx*qx + qy*qy + qz*qz); | ||
SET_VEC(vector, qx/q, qy/q, qz/q); | ||
|
||
//Moon-Riste-Koehler notation choose z as pointing along field/polarisation axis | ||
//totally different to what is used in SASview (historical reasons) | ||
SET_VEC(Mvectorreal, mxreal, myreal, mzreal); | ||
SET_VEC(Mvectorimag, mximag, myimag, mzimag); | ||
|
||
SET_VEC(Pvector, 0, 0, 1); | ||
SET_VEC(perpy, 0, 1, 0); | ||
SET_VEC(perpx, 1, 0, 0); | ||
//Magnetic scattering vector Mperp could be simplified like in Moon-Riste-Koehler | ||
//leave the generic computation just to check | ||
ORTH_VEC(Mperpreal, Mvectorreal, vector); | ||
ORTH_VEC(Mperpimag, Mvectorimag, vector); | ||
|
||
|
||
sld[0] = nuc - SCALAR_VEC(Pvector,Mperpreal); // dd.real => sld - D Pvector \cdot Mperp | ||
sld[1] = +SCALAR_VEC(Pvector,Mperpimag); //dd.imag = nuc_img - SCALAR_VEC(Pvector,Mperpimg); nuc_img only exist for noncentrosymmetric nuclear structures; | ||
sld[2] = nuc + SCALAR_VEC(Pvector,Mperpreal); // uu => sld + D Pvector \cdot Mperp | ||
sld[3] = -SCALAR_VEC(Pvector,Mperpimag); //uu.imag | ||
|
||
sld[4] = SCALAR_VEC(perpy,Mperpreal)+SCALAR_VEC(perpx,Mperpimag); // du.real => real part along y + imaginary part along x | ||
sld[5] = SCALAR_VEC(perpy,Mperpimag)-SCALAR_VEC(perpx,Mperpreal); // du.imag => imaginary component along y - i *real part along x | ||
sld[6] = SCALAR_VEC(perpy,Mperpreal)-SCALAR_VEC(perpx,Mperpimag); // ud.real => real part along y - imaginary part along x | ||
sld[7] = SCALAR_VEC(perpy,Mperpimag)+SCALAR_VEC(perpx,Mperpreal); // ud.imag => imaginary component along y + i * real part along x | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
//Core-shell form factor for anisotropy field (Hkx, Hky and Hkz), Nuc and lonitudinal magnetization Mz | ||
static double | ||
form_volume(double radius, double thickness) | ||
{ | ||
if( radius + thickness > radius + thickness) | ||
return M_4PI_3 * cube(radius + thickness); | ||
else | ||
return M_4PI_3 * cube(radius + thickness); | ||
|
||
} | ||
|
||
|
||
|
||
static double fq(double q, double radius, | ||
double thickness, double core_sld, double shell_sld, double solvent_sld) | ||
{ | ||
const double form = core_shell_fq(q, | ||
radius, | ||
thickness, | ||
core_sld, | ||
shell_sld, | ||
solvent_sld); | ||
return form; | ||
} | ||
|
||
|
||
static double reduced_field(double q, double Ms, double Hi, | ||
double A) | ||
{ | ||
// q in 10e10 m-1, A in 10e-12 J/m, mu0 in 1e-7 | ||
return Ms / (fmax(Hi, 1.0e-6) + 2.0 * A * 4.0 * M_PI / Ms * q * q * 10.0); | ||
|
||
} | ||
|
||
static double DMI_length(double Ms, double D, double qval) | ||
{ | ||
return 2.0 * D * 4.0 * M_PI / Ms / Ms * qval ; //q in 10e10 m-1, A in 10e-3 J/m^2, mu0 in 4 M_PI 1e-7 | ||
} | ||
|
||
//Mz is defined as the longitudinal magnetisation component along the magnetic field. | ||
//In the approach to saturation this component is (almost) constant with magnetic | ||
//field and simplfy reflects the nanoscale variations in the saturation magnetisation | ||
//value in the sample. The misalignment of the magnetisation due to perturbing | ||
//magnetic anisotropy or dipolar magnetic fields in the sample enter Mx and My, | ||
//the two transversal magnetisation components, reacting to a magnetic field. | ||
//The micromagnetic solution for the magnetisation are from Michels et al. PRB 94, 054424 (2016). | ||
|
||
static double fqMxreal( double qx, double qy, double qz, double Mz, double Hkx, double Hky, double Hi, double Ms, double A, double D) | ||
{ | ||
double qsq = qx * qx + qy * qy + qz * qz; | ||
double q = sqrt(qsq); | ||
double Hr = reduced_field(q, Ms, Hi, A); | ||
double DMI = DMI_length(Ms, D,q); | ||
double DMIz = DMI_length(Ms, D,qz); | ||
double denominator = (qsq + Hr * (qx * qx + qy * qy) - square(Hr * DMIz * q)) / Hr; | ||
double f = (Hkx * (qsq + Hr * qy * qy) - Ms * Mz * qx * qz * (1.0 + Hr * square(DMI)) - Hky * Hr * qx * qy) / denominator; | ||
return f; | ||
} | ||
|
||
static double fqMximag(double qx, double qy, double qz, double Mz, double Hkx, double Hky, double Hi, double Ms, double A, double D) | ||
{ | ||
double qsq = qx * qx + qy * qy + qz * qz; | ||
double q = sqrt(qsq); | ||
double Hr = reduced_field(q, Ms, Hi, A); | ||
double DMI = DMI_length(Ms, D,q); | ||
double DMIz = DMI_length(Ms, D,qz); | ||
double DMIy = DMI_length(Ms, D,qy); | ||
double denominator = (qsq + Hr * (qx * qx + qy * qy) - square(Hr * DMIz * q)) / Hr; | ||
double f = - qsq * (Ms * Mz * (1.0 + Hr) * DMIy + Hky * Hr * DMIz) / denominator; | ||
return f; | ||
} | ||
|
||
static double fqMyreal( double qx, double qy, double qz, double Mz, double Hkx, double Hky, double Hi, double Ms, double A, double D) | ||
{ | ||
double qsq = qx * qx + qy * qy + qz * qz; | ||
double q = sqrt(qsq); | ||
double Hr = reduced_field(q, Ms, Hi, A); | ||
double DMI = DMI_length(Ms, D,q); | ||
double DMIz = DMI_length(Ms, D,qz); | ||
double denominator = (qsq + Hr * (qx * qx + qy * qy) - square(Hr * DMIz * q))/Hr; | ||
double f = (Hky * (qsq + Hr * qx * qx) - Ms * Mz * qy * qz * (1.0 + Hr * square(DMI)) - Hkx * Hr * qx * qy)/denominator; | ||
return f; | ||
} | ||
|
||
static double fqMyimag( double qx, double qy, double qz, double Mz, double Hkx, double Hky, double Hi, double Ms, double A, double D) | ||
{ | ||
double qsq = qx * qx + qy * qy + qz * qz; | ||
double q = sqrt(qsq); | ||
double Hr = reduced_field(q, Ms, Hi, A); | ||
double DMI = DMI_length(Ms, D,q); | ||
double DMIx = DMI_length(Ms, D,qx); | ||
double DMIz = DMI_length(Ms, D,qz); | ||
double denominator = (qsq + Hr * (qx * qx + qy * qy) - square(Hr * DMIz * q))/Hr; | ||
double f = qsq * (Ms * Mz * (1.0 + Hr) * DMIx - Hkx * Hr * DMIz)/denominator; | ||
return f; | ||
} | ||
|
||
static double | ||
Calculate_Scattering(double q, double cos_theta, double sin_theta, double radius, double thickness, double nuc_sld_core, double nuc_sld_shell, double nuc_sld_solvent, double mag_sld_core, double mag_sld_shell, double mag_sld_solvent, double hk_sld_core, double Hi, double Ms, double A, double D, double up_i, double up_f, double alpha, double beta) | ||
{ | ||
double qrot[3]; | ||
set_scatvec(qrot,q,cos_theta, sin_theta, alpha, beta); | ||
// 0=dd.real, 1=dd.imag, 2=uu.real, 3=uu.imag, 4=du.real, 6=du.imag, 7=ud.real, 5=ud.imag | ||
double weights[8]; | ||
set_weights(up_i, up_f, weights); | ||
|
||
double mz = fq(q, radius, thickness, mag_sld_core, mag_sld_shell, mag_sld_solvent); | ||
double nuc = fq(q, radius, thickness, nuc_sld_core, nuc_sld_shell, nuc_sld_solvent); | ||
double hk = fq(q, radius, 0, hk_sld_core, 0, 0); | ||
|
||
double cos_gamma, sin_gamma; | ||
double sld[8]; | ||
//loop over random anisotropy axis with isotropic orientation gamma for Hkx and Hky | ||
//To be modified for textured material see also Weissmueller et al. PRB 63, 214414 (2001) | ||
double total_F2 = 0.0; | ||
for (int i = 0; i<GAUSS_N ;i++) { | ||
const double gamma = M_PI * (GAUSS_Z[i] + 1.0); // 0 .. 2 pi | ||
SINCOS(gamma, sin_gamma, cos_gamma); | ||
//Only the core of the defect/particle in the matrix has an effective | ||
//anisotropy (for simplicity), for the effect of different, more complex | ||
// spatial profile of the anisotropy see Michels PRB 82, 024433 (2010) | ||
double Hkx = hk * sin_gamma; | ||
double Hky = hk * cos_gamma; | ||
|
||
double mxreal = fqMxreal(qrot[0], qrot[1], qrot[2], mz, Hkx, Hky, Hi, Ms, A, D); | ||
double mximag = fqMximag(qrot[0], qrot[1], qrot[2], mz, Hkx, Hky, Hi, Ms, A, D); | ||
double myreal = fqMyreal(qrot[0], qrot[1], qrot[2], mz, Hkx, Hky, Hi, Ms, A, D); | ||
double myimag = fqMyimag(qrot[0], qrot[1], qrot[2], mz, Hkx, Hky, Hi, Ms, A, D); | ||
|
||
mag_sld(qrot[0], qrot[1], qrot[2], mxreal, mximag, myreal, myimag, mz, 0, nuc, sld); | ||
double form = 0.0; | ||
for (unsigned int xs = 0; xs<8; xs++) { | ||
if (weights[xs] > 1.0e-8) { | ||
// Since the cross section weight is significant, set the slds | ||
// to the effective slds for this cross section, call the | ||
// kernel, and add according to weight. | ||
// loop over uu, ud real, du real, dd, ud imag, du imag | ||
form += weights[xs] * sld[xs] * sld[xs]; | ||
} | ||
} | ||
total_F2 += GAUSS_W[i] * form ; | ||
} | ||
return total_F2; | ||
} | ||
|
||
|
||
static double | ||
Iqxy(double qx, double qy, double radius, double thickness, double nuc_sld_core, double nuc_sld_shell, double nuc_sld_solvent, double mag_sld_core, double mag_sld_shell, double mag_sld_solvent, double hk_sld_core, double Hi, double Ms, double A, double D, double up_i, double up_f, double alpha, double beta) | ||
{ | ||
double sin_theta, cos_theta; | ||
const double q = sqrt(qx * qx + qy * qy); | ||
if (q > 1.0e-16 ) { | ||
cos_theta = qx/q; | ||
sin_theta = qy/q; | ||
} else { | ||
cos_theta = 0.0; | ||
sin_theta = 0.0; | ||
} | ||
|
||
double total_F2 = Calculate_Scattering(q, cos_theta, sin_theta, radius, thickness, nuc_sld_core, nuc_sld_shell, nuc_sld_solvent, mag_sld_core, mag_sld_shell, mag_sld_solvent, hk_sld_core, Hi, Ms, A, D, up_i, up_f, alpha, beta); | ||
|
||
return 0.5 * 1.0e-4 * total_F2; | ||
|
||
} | ||
|
||
|
||
|
||
static double | ||
Iq(double q, double radius, double thickness, double nuc_sld_core, double nuc_sld_shell, double nuc_sld_solvent, double mag_sld_core, double mag_sld_shell, double mag_sld_solvent, double hk_sld_core, double Hi, double Ms, double A, double D, double up_i, double up_f, double alpha, double beta) | ||
{ | ||
// slots to hold sincos function output of the orientation on the detector plane | ||
double sin_theta, cos_theta; | ||
double total_F1D = 0.0; | ||
for (int j = 0; j<GAUSS_N ;j++) { | ||
|
||
const double theta = M_PI * (GAUSS_Z[j] + 1.0); // 0 .. 2 pi | ||
SINCOS(theta, sin_theta, cos_theta); | ||
|
||
double total_F2 = Calculate_Scattering(q, cos_theta, sin_theta, radius, thickness, nuc_sld_core, nuc_sld_shell, nuc_sld_solvent, mag_sld_core, mag_sld_shell, mag_sld_solvent, hk_sld_core, Hi, Ms, A, D, up_i, up_f, alpha, beta); | ||
total_F1D += GAUSS_W[j] * total_F2 ; | ||
} | ||
//convert from [1e-12 A-1] to [cm-1] | ||
return 0.25 * 1.0e-4 * total_F1D; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
r""" | ||
Definition | ||
---------- | ||
This model is a micromagnetic approach to analyse the SANS that arises from | ||
nanoscale variations in the magnitude and orientation of the magnetization in | ||
bulk ferromagnets in the approach to magnetic saturation (single domain state). | ||
Typical materials are cold-worked elemental magnets, hard and soft magnetic | ||
nanocomposites, amorphous alloys and precipitates in magnetic steel [#Michels2014]_. | ||
The magnetic SANS depends on the magnetic interactions, the magnetic microstructure | ||
(defect/particle size, magnetocrystalline anisotropy, saturation magnetisation) | ||
and on the applied magnetic field. As shown in [#Michels2016]_ near magnetic | ||
saturation the scattering cross-section can be evaluated by means of micromagnetic theory | ||
.. math:: | ||
I(\mathbf{Q}) = I_{nuc} + I_{mag}(\mathbf{Q},H), | ||
with the field-independent nuclear and magnetic SANS cross section (due | ||
to nanoscale spatial variations of the magnetisation). | ||
.. math:: | ||
I_{mag}(\mathbf{Q},H)= S_K(Q) R_K(\mathbf{Q}, H_i) + S_M(Q) R_M(\mathbf{Q}, H_i), | ||
with $H_i$ the internal field, i.e. the external magnetic field corrected for | ||
demagnetizing effects and the influence of the magnetodipolar field and of the | ||
magnetic anisotropy [#Bick2013]_. This magnetic field dependence of the scattering | ||
reflects the increasing magnetisation misalignment with decreasing | ||
externally applied magnetic field with a contribution $S_K \times R_K$ due to | ||
perturbations around magnetic anisotropy fields and a term $S_M \times R_M$ | ||
related to magnetostatic fields. The magnetic moments decorate perturbations in the | ||
microstructure (precipitates, grain boundaries etc). | ||
The anisotropy-field function $S_K$ depends on the Fourier transform of the magnetic | ||
anisotropy distribution (strength and orientation) in the material, and the | ||
scattering function of the longitudinal magnetisation $S_M$ reflects the | ||
variations of the saturation magnetisation, e.g. jumps at the particle-matrix | ||
interface. $R_K$ and $R_M$ denote the micromagnetic response functions that | ||
describe the magnetisation distribution around a perturbation in magnetic | ||
anisotropy and flucutations in the saturation magnetisation value. | ||
.. figure:: img/micromagnetic_FF.png | ||
Magnetisation distribution around (left) a particle with magnetic easy axis | ||
in the vertical direction and (right) a precipitation with a magnetisation | ||
that is higher than the matrix phase. | ||
The micromagnetic response functions depend on magnetic material parameters $M_S$: | ||
average saturation magnetisation of the material, $H_i$: the internal magnetic | ||
field, $A$ the average exchange-stiffness constant. In the vicinity of lattice | ||
imperfection in ferromagnetic materials, antisymmetric Dzyaloshinskii–Moriya | ||
interaction (DMI) can occur due to the local structural inversion symmetry | ||
breaking [#Arrott1963]_. DMI with strength $D$ can give rise to nonuniform spin | ||
textures resulting in a polarization-dependent asymmetric scattering term for | ||
polycrystalline ferromagnetic with a centrosymmetric crystal structure [#Michels2016]_. | ||
We assume (for simplicity) an isotropic microstructure (for $S_M$) and random | ||
orientation of magnetic easy axes (additionally for $S_K$) such that the | ||
contributions of the magnetic microstructure only depend on the magnitude of $q$. | ||
Considerations for a microstructure with a prefered orientation (texture) can be | ||
found in [#Weissmueller2001]_. In the code the averaging procedure over the random | ||
anisotropy is explicitely performed. A specific orientation distribution can be | ||
implemented by rewriting the model. | ||
The magnetic field is oriented with an inclination of $\alpha$ to the neutron beam | ||
and rotated by $\beta$. The model for the nuclear scattering amplitude, saturation | ||
magnetisation is based on spherical particles with a core shell structure. For | ||
simplicity, only the core has an effective anisotropy, that is varying randomly | ||
in direction from particle to particle. The effect of different, more complex | ||
spatial profiles of the anisotropy can be seen in [#Michels2010]_. | ||
The magnetic scattering length density (SLD) is defined as | ||
$\rho_{\mathrm{mag}}=b_H M_S$, where $b_H= 2.91*10^{8}A^{-1}m^{-1}$ and $M_S$ | ||
is the saturation magnetisation (in $A/m$). | ||
The fraction of "upward" neutrons before ('up_frac_i') and after the sample | ||
('up_frac_f') must range between 0 to 1, with 0.5 denoting an unpolarised beam. | ||
Note that a fit may result in a negative magnetic SLD, and hence magnetisation, | ||
when the polarisation state is inverted, i.e. if you have analysed for a $I_{00}$ | ||
state wheras your data are $I_{11}$. The model allows to construct the 4 | ||
spin-resolved cross sections (non-spin-flip $I_{00}$, $I_{11}$ and spin-flip, here | ||
$I_{01}=I_{10}$), half-polarised SANS (SANSpol, incoming polarised beam $I_0$ and | ||
$I_1$, no analysis after sample 'up_frac_f'$=0.5$), and unpolarised beam | ||
('up_frac_i'$=$'up_frac_f'$=0.5$). Differences and other combinations between | ||
polarised scattering cross section, e.g. to obtain the nuclear-magnetic | ||
interference scattering, or subtraction of the residual scattering of the high | ||
field reference state can be constructed with a custom model (Fitting> | ||
Add/Multiply Model) and using approbriate scales. For dense systems, special | ||
care has to be taken as the nculear structure factor (arrangement of particles) | ||
does not need to be identical with the magnetic microstructure e.g. local | ||
textures and correlations between easy axes (see [#Honecker2020]_ for further | ||
details). The use of structure model is therefore strongly discouraged. Better | ||
$I_{nuc}$, $S_K$ and $S_M$ are fit independent from each other in a model-free way. | ||
References | ||
---------- | ||
.. [#Arrott1963] A. Arrott, J. Appl. Phys. 34, 1108 (1963). | ||
.. [#Weissmueller2001] J. Weissmueller et al., *Phys. Rev. B* 63, 214414 (2001). | ||
.. [#Bick2013] J.-P. Bick et al., *Appl. Phys. Lett.* 102, 022415 (2013). | ||
.. [#Michels2010] A. Michels et al., *Phys. Rev. B* 82, 024433 (2010). | ||
.. [#Michels2014] A. Michels, *J. Phys.: Condens. Matter* 26, 383201 (2014). | ||
.. [#Michels2016] A. Michels et al., *Phys. Rev. B* 94, 054424 (2016). | ||
.. [#Honecker2020] D. Honecker, L. Fernandez Barguin, and P. Bender, *Phys. Rev. B* 101, 134401 (2020). | ||
Authorship and Verification | ||
---------------------------- | ||
* **Author:** Dirk Honecker **Date:** January 14, 2021 | ||
* **Last Modified by:** Dirk Honecker **Date:** September 23, 2024 | ||
* **Last Reviewed by:** | ||
""" | ||
|
||
import numpy as np | ||
from numpy import pi, inf | ||
|
||
name = "micromagnetic_FF_3D" | ||
title = "Field-dependent magnetic microstructure around imperfections in bulk ferromagnets" | ||
description = """ | ||
I(q) = A (F_N^2(q)+ C F_N F_M + D F_M^2) +B(H) I_mag(q,H) | ||
A: weighting function =1 for unpolarised beam and non-neutron-spin-flip scattering, zero for spin-flip scattering. The terms in the bracket are the residual scattering at perfectly saturating magnetic field. | ||
B(H): weighting function for purely magnetic scattering I_mag(q,H) due to misaligned magnetic moments, different for the various possible spin-resolved scattering cross sections | ||
C: weighting function for nuclear-magnetic interference scattering | ||
F_N: nuclear form factor | ||
F_M: magnetic form factor | ||
The underlying defect can have a core-shell structure. | ||
""" | ||
category = "shape:sphere" | ||
|
||
# pylint: disable=bad-whitespace, line-too-long | ||
# ["name", "units", default, [lower, upper], "type","description"], | ||
parameters = [["radius", "Ang", 50., [0, inf], "volume", "Structural radius of the core"], | ||
["thickness", "Ang", 40., [0, inf], "volume", "Structural thickness of shell"], | ||
["nuc_sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "", "Core scattering length density"], | ||
["nuc_sld_shell", "1e-6/Ang^2", 1.7, [-inf, inf], "", "Scattering length density of shell"], | ||
["nuc_sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "", "Solvent scattering length density"], | ||
["mag_sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "", "Magnetic scattering length density of core"], | ||
["mag_sld_shell", "1e-6/Ang^2", 1.7, [-inf, inf], "", "Magnetic scattering length density of shell"], | ||
["mag_sld_solvent", "1e-6/Ang^2", 3.0, [-inf, inf], "", "Magnetic scattering length density of solvent"], | ||
["hk_sld_core", "1e-6/Ang^2", 1.0, [0, inf], "", "Anisotropy field of defect"], | ||
["Hi", "T", 2.0, [0, inf], "", "Effective field inside the material"], | ||
["Ms", "T", 1.0, [0, inf], "", "Volume averaged saturation magnetisation"], | ||
["A", "pJ/m", 10.0, [0, inf], "", "Average exchange stiffness constant"], | ||
["D", "mJ/m^2", 0.0, [0, inf], "", "Average DMI constant"], | ||
["up_i", "None", 0.5, [0, 1], "", "Polarisation incoming beam"], | ||
["up_f", "None", 0.5, [0, 1], "", "Polarisation outgoing beam"], | ||
["alpha", "None", 90, [0, 180], "", "Inclination of field to neutron beam"], | ||
["beta", "None", 0, [0, 360], "", "Rotation of field around neutron beam"], | ||
] | ||
# pylint: enable=bad-whitespace, line-too-long | ||
|
||
|
||
|
||
|
||
source = ["lib/sas_3j1x_x.c", "lib/core_shell.c", "lib/gauss76.c", "lib/magnetic_functions.c", "micromagnetic_FF_3D.c"] | ||
structure_factor = False | ||
have_Fq = False | ||
single=False | ||
opencl = False | ||
|
||
|
||
def random(): | ||
"""Return a random parameter set for the model.""" | ||
outer_radius = 10**np.random.uniform(1.3, 4.3) | ||
# Use a distribution with a preference for thin shell or thin core | ||
# Avoid core,shell radii < 1 | ||
radius = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1 | ||
thickness = outer_radius - radius | ||
pars = dict( | ||
radius=radius, | ||
thickness=thickness, | ||
|
||
) | ||
return pars | ||
|
||
|
||
|
||
tests = [ | ||
[{},1.002266990452620e-03, 7.461046163627724e+03], | ||
[{},(0.0688124, -0.0261013), 22.024], | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters