wppm_macros
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
wppm_macros [2018/10/24 15:38] – johnsoevans | wppm_macros [2022/11/03 15:08] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== WPPM Macros ====== | ||
+ | Paolo Scardi and co-workers have provided a set of macros for their WPPM methods in TOPAS. | ||
+ | |||
+ | The publication is at: [[ http:// | ||
+ | |||
+ | Macros implementing the main concepts of the whole powder pattern modelling approach have been written for TOPAS. Size and strain broadening components of the diffraction line profiles can be convolved with the instrumental profile already available among the standard commands of TOPAS. Specific macros are presented with examples of applications including plastically deformed powders and atomistic simulations. A macro is presented for the modelling of surface relaxation effects in spherical nanocrystals. | ||
+ | |||
+ | Note: delete any old wppm macros you have around before using these. | ||
+ | |||
+ | <code topas> | ||
+ | |||
+ | ' WPPM macros by P. Scardi, C. Perez-Demydenko & C.L. Azanza Ricardo | ||
+ | ' See also: P. Scardi, C. Perez-Demydenko, | ||
+ | ' The following macros can be used with any space group; additional macros specific to cubic phases are available | ||
+ | ' email: Paolo.Scardi@unitn.it | ||
+ | |||
+ | macro WPPM_Sphere(RRc, | ||
+ | { | ||
+ | If_Prm_Eqn_Rpt(RRc, | ||
+ | WPPM_ft_conv = 1 - 0.75*WPPM_L/ | ||
+ | |||
+ | ' | ||
+ | WPPM_L_max = 2*CeV(RRc, RRv); | ||
+ | WPPM_th2_range = 55; | ||
+ | } | ||
+ | macro WPPM_Sphere_LogNormDIST(muc, | ||
+ | { | ||
+ | #m_argu muc | ||
+ | #m_argu sigc | ||
+ | If_Prm_Eqn_Rpt(muc, | ||
+ | If_Prm_Eqn_Rpt(sigc, | ||
+ | WPPM_ft_conv = | ||
+ | { | ||
+ | def u = CeV(muc, muv); | ||
+ | def sig = CeV(sigc, sigv); | ||
+ | fn M(n) = 0.5 Exp(- n (u + (3 - 0.5 n) sig^2)); | ||
+ | fn wppm_Ln(kc) = Get(WPPM_Ln_k) + Ln(kc Get(WPPM_dL)); | ||
+ | fn q(n) { | ||
+ | | ||
+ | Erfc_Approx( ( wppm_Ln(1) - u - (3-n) sig^2) / (sig Sqrt(2))) | ||
+ | WPPM_L^n | ||
+ | M(n); | ||
+ | } | ||
+ | return q(0) - 1.5 q(1) + 0.5 q(3); | ||
+ | } | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | macro getInvariant(sg, | ||
+ | { | ||
+ | #if Or(sg == 1, sg == 2); ' | ||
+ | | ||
+ | | ||
+ | #elseif And(sg >= 3, sg <= 15); ' | ||
+ | If (And(Constant(Get(al)) == 90, Constant(Get(ga)) == 90), ' unique axis b | ||
+ | E1*H^4 + E2*K^4 + E3*L^4 + 2*(E4*H*H*L*L + E5*K*K*L*L + E6*H*H*K*K) + 4*(E7*(H^3)*L + E8*H*(L^3) + E9*H*K*K*L), | ||
+ | If (And(Constant(Get(al)) == 90, Constant(Get(be)) == 90), ' unique axis c | ||
+ | | ||
+ | " | ||
+ | ) | ||
+ | ) | ||
+ | #elseif And(sg >= 16, sg <= 74); ' | ||
+ | | ||
+ | |||
+ | #elseif And(sg >= 75, sg <= 88); ' | ||
+ | | ||
+ | |||
+ | #elseif And(sg >= 89, sg <= 142); ' | ||
+ | | ||
+ | |||
+ | #elseif And(sg >= 143, sg <= 148); ' | ||
+ | #if Or(sg == 146, sg == 148); ' | ||
+ | If (Constant(Get(ga)) == 120, | ||
+ | | ||
+ | If (Constant(Get(ga)) == 60, | ||
+ | E1*(H*H + H*K + K*K)^2 + 2*E2*L*L*(H*H + H*K + K*K) + E3*L^4 + (4/ | ||
+ | E1*(H^4 + K^4 + L^4) + 2*E2*(H*H*K*K + H*H*L*L + K*K*L*L) + 4*E3*((H^3)*K + (K^3)*L + H*(L^3)) + 4*E4*(H*(K^3) + (H^3)*L + K*(L^3))+ 4*E5*H*K*L*(H + K + L) | ||
+ | ) | ||
+ | ) | ||
+ | # | ||
+ | If (Constant(Get(ga)) == 120, | ||
+ | | ||
+ | | ||
+ | ) | ||
+ | # | ||
+ | | ||
+ | #elseif And(sg >= 149, sg <= 167); ' | ||
+ | #if Or(sg ==150, sg ==152, sg ==154, sg ==155, sg ==156, sg ==158, sg ==160, sg ==161, sg ==164, sg ==165 , sg ==166, sg ==167); ' | ||
+ | #if Or(sg == 155, sg == 160, sg == 161, sg == 166, sg == 167); ' | ||
+ | If (Constant(Get(ga)) == 120, | ||
+ | E1*(H*H - H*K + K*K)^2 + 2*E2*L*L*(H*H - H*K + K*K) + E3*L^4 + 4*E4*H*K*L*(H - K), | ||
+ | If (Constant(Get(ga)) == 60, | ||
+ | | ||
+ | | ||
+ | ) | ||
+ | ) | ||
+ | #else | ||
+ | If (Constant(Get(ga)) == 120, | ||
+ | E1*(H*H - H*K + K*K)^2 + 2*E2*L*L*(H*H - H*K + K*K) + E3*L^4 + 4*E4*H*K*L*(H - K), | ||
+ | E1*(H*H + H*K + K*K)^2 + 2*E2*L*L*(H*H + H*K + K*K) + E3*L^4 + 4*E4*H*K*L*(H + K) ' 60deg | ||
+ | ) | ||
+ | # | ||
+ | #else ' | ||
+ | If (Constant(Get(ga)) == 120, | ||
+ | | ||
+ | | ||
+ | ) | ||
+ | # | ||
+ | | ||
+ | #elseif And(sg >= 168, sg <= 194); ' | ||
+ | If (Constant(Get(ga)) == 120, | ||
+ | E1*(H*H - H*K + K*K)^2 + 2*E2*L*L*(H*H - H*K + K*K) + E3*L^4, | ||
+ | E1*(H*H + H*K + K*K)^2 + 2*E2*L*L*(H*H + H*K + K*K) + E3*L^4 ' 60deg | ||
+ | ) | ||
+ | #elseif And(sg >= 195, sg <= 230); ' | ||
+ | | ||
+ | #else | ||
+ | #endif | ||
+ | } | ||
+ | macro Out_Invariant(file, | ||
+ | { | ||
+ | ' E1 to E9 for space groups 3 to 15 (2/m) | ||
+ | Out_Invariant(file, | ||
+ | } | ||
+ | macro Out_Invariant(file, | ||
+ | { | ||
+ | ' E1 to E6 for space groups 16 to 64 (mmm) | ||
+ | Out_Invariant(file, | ||
+ | } | ||
+ | |||
+ | macro Out_Invariant(file, | ||
+ | { | ||
+ | ' E1 to E5 for space groups 75 to 88 (4/m) and 143 to 148 (-3) | ||
+ | Out_Invariant(file, | ||
+ | } | ||
+ | macro Out_Invariant(file, | ||
+ | { | ||
+ | ' E1 to E4 for space groups 89 to 142 (4/mmm) and 149 to 167 (-3m) | ||
+ | Out_Invariant(file, | ||
+ | } | ||
+ | macro Out_Invariant(file, | ||
+ | { | ||
+ | ' E1 to E3 for space groups 168 to 194 (6/m and 6/mmm) | ||
+ | Out_Invariant(file, | ||
+ | } | ||
+ | macro Out_Invariant(file, | ||
+ | { | ||
+ | ' E1 to E2 for space groups 195 to 230 (m-3 and m-3m) | ||
+ | Out_Invariant(file, | ||
+ | } | ||
+ | macro Out_Invariant(file, | ||
+ | { | ||
+ | out file | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | load out_record out_fmt out_eqn | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | { | ||
+ | ' E1 to E9 for space groups 3 to 15 (2/m) | ||
+ | WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | { | ||
+ | ' E1 to E6 for space groups 16 to 64 (mmm) | ||
+ | WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | { | ||
+ | ' E1 to E5 for space groups 75 to 88 (4/m) and 143 to 148 (-3) | ||
+ | WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | { | ||
+ | ' E1 to E4 for space groups 89 to 142 (4/mmm) and 149 to 167 (-3m) | ||
+ | WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | { | ||
+ | ' E1 to E3 for space groups 168 to 194 (6/m and 6/mmm) | ||
+ | WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | { | ||
+ | ' E1 to E2 for space groups 195 to 230 (m-3 and m-3m) | ||
+ | WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantWilkens(rhoc, | ||
+ | { | ||
+ | #m_argu rhoc | ||
+ | #m_argu Rec | ||
+ | If_Prm_Eqn_Rpt(rhoc, | ||
+ | If_Prm_Eqn_Rpt(Rec , Rev , min 1 max = Min(2 Val + .0001, 0.100);) | ||
+ | | ||
+ | WPPM_ft_conv = { | ||
+ | def invariantTerm_0 = getInvariant(wsg, | ||
+ | def invariantTerm = If (invariantTerm_0 < 0, 1000, invariantTerm_0); | ||
+ | def dstar = 1/ | ||
+ | def aa = Constant(Get(a) 0.1); | ||
+ | def strainINV = invariantTerm/ | ||
+ | def rhoVal = CeV(rhoc, rhov); | ||
+ | def fact = Pi burgers burgers rhoVal dstar dstar strainINV 0.01 0.5; | ||
+ | def Reval = CeV(Rec, Rev); | ||
+ | def eta = Abs(WPPM_L/ | ||
+ | def fstar = If ( eta < 1, -Ln(eta) + 7/4 - Ln(2) + eta*eta/6 - (32*eta*eta*eta)/ | ||
+ | def result = If (WPPM_L == 0, 1, Exp(-fact*(WPPM_L*WPPM_L*fstar))); | ||
+ | | ||
+ | } | ||
+ | WPPM_break_on_small = 1e-7; | ||
+ | WPPM_L_max 1000 | ||
+ | WPPM_th2_range = 30; | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantPAH(ac, | ||
+ | { | ||
+ | ' E1 to E9 for space groups 3 to 15 (2/m) | ||
+ | WPPM_Strain_InvariantPAH(ac, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantPAH(ac, | ||
+ | { | ||
+ | ' E1 to E6 for space groups 16 to 64 (mmm) | ||
+ | WPPM_Strain_InvariantPAH(ac, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantPAH(ac, | ||
+ | { | ||
+ | ' E1 to E5 for space groups 75 to 88 (4/m) and 143 to 148 (-3) | ||
+ | WPPM_Strain_InvariantPAH(ac, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantPAH(ac, | ||
+ | { | ||
+ | ' E1 to E4 for space groups 89 to 142 (4/mmm) and 149 to 167 (-3m) | ||
+ | WPPM_Strain_InvariantPAH(ac, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantPAH(ac, | ||
+ | { | ||
+ | ' E1 to E3 for space groups 168 to 194 (6/m and 6/mmm) | ||
+ | WPPM_Strain_InvariantPAH(ac, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantPAH(ac, | ||
+ | { | ||
+ | ' E1 to E2 for space groups 195 to 230 (m-3 and m-3m) | ||
+ | WPPM_Strain_InvariantPAH(ac, | ||
+ | } | ||
+ | macro WPPM_Strain_InvariantPAH(ac, | ||
+ | { | ||
+ | #m_argu ac | ||
+ | #m_argu bc | ||
+ | If_Prm_Eqn_Rpt(ac, | ||
+ | If_Prm_Eqn_Rpt(bc, | ||
+ | WPPM_ft_conv = { | ||
+ | def invariantTerm_0 = getInvariant(wsg, | ||
+ | def invariantTerm | ||
+ | def dstar = 1/ | ||
+ | def aa = Constant(Get(a) 0.1); | ||
+ | def strainINV = invariantTerm/ | ||
+ | def fact = 2*Pi*Pi*dstar*dstar*strainINV; | ||
+ | def aVal = CeV(ac, av)*1e-5; | ||
+ | def bVal = CeV(bc, bv)*1e-5; | ||
+ | return Exp(-fact*(aVal*WPPM_L+bVal*WPPM_L*WPPM_L)); | ||
+ | } | ||
+ | WPPM_break_on_small = 1e-7; | ||
+ | WPPM_L_max 1000 | ||
+ | WPPM_th2_range = 30; | ||
+ | } | ||
+ | |||
+ | |||
+ | </ |