Table of Contents
Macro to output .mem file and .prf file for MEM analysis in Dysnomia
The macros in this page output .mem file and .prf file for Dysnomia to calculate electron density in unit cell based on Maximum Entropy Method (MEM) analysis. The format of .mem and .prf files are based on the Dysnomia example files.
This macro calls other macros “Atomic_Number” and “sg_num”.
This macro has been tested working in TOPAS v6.
The macros
Out_MEM
This macro exports the real part and imaginary part of observed structure factors, and their errors for each reflection. This macro also calls “Out_PRF” macro to export a Preference file .prf for Dysnomia to perform MEM analysis. The macro parameter “sgs”, Space Group Symbel needs be in lower case without any gap nor underscore, but needs be quoted by double quotes, e.g. “r-3c”
macro Out_MEM(phasename, sgs) { 'space group symbel 'sgs' needs be lower case without gap nor underscore, but with double quotes, e.g. "r-3c" #if (Run_Number == 0) out phasename##_dys.mem append Out_String("# Title (up to 70 character) \n") Out(Get(phase_name), "%s ( Powder X-ray Data )\n") Out_String("# a b c alpha beta gamma\n") Out(Get(a), "%10.5f") Out(Get(b), "%10.5f") Out(Get(c), "%10.5f") Out(Get(al), "%10.5f") Out(Get(be), "%10.5f") Out(Get(ga), "%10.5f\n") Out_String("# P.O. correction\n") Out_String("# When TORAYA & MARUMO type function is used add P option.\n") Out_String("# IPTYP : -1 = No Correction 0 = Plate Like 1 = Needle Like\n") Out_String("# POP1 POP2 IPTYP JPH JPK JPL\n") Out_String(" 0.0000000 0.0000000 -1 0 0 0 P\n") Out_String("# SPG ORG NX NY NZ\n") Out(sg_num(sgs), " %.0f 1 ") Out(6(Round(Get(a)/0.07/6)+1), "%.0f ") Out(6(Round(Get(b)/0.07/6)+1), "%.0f ") Out(6(Round(Get(c)/0.07/6)+1), "%.0f\n") Out_String("# Total charge lambda\n") Out(Total_e_in_Cell, "%14.7f") Out_String(" 0.0010000\n") Out_String("# NREF1 need to count manually\n") Out_String(" 64\n") Out_String("# h k l Fo(R) Fo(I) sigma(F)") phase_out phasename##_dys.mem append load out_record out_fmt out_eqn { "\n%5.0f" = H; " %4.0f" = K; " %4.0f" = L; '" %4.0f" = M; '" %12.2f" = I_no_scale_pks/M/Get(scale); '|F|^2 '" %11.4f" = A01-B11; 'Real '" %11.4f" = A11+B01; 'Imaginary " %14.7f" = Sqrt(Iobs_no_scale_pks/M/Get(scale)) Cos(If((A01-B11)>0, ArcTan((A11+B01)/(A01-B11)), ArcTan((A11+B01)/(A01-B11)) +Pi)); " %14.7f" = Sqrt(Iobs_no_scale_pks/M/Get(scale)) Sin(If((A01-B11)>0, ArcTan((A11+B01)/(A01-B11)), ArcTan((A11+B01)/(A01-B11)) +Pi)); " %14.7f" = Sqrt(Iobs_no_scale_pks)/Get(scale) Sqrt((Iobs_no_scale_pks_err/Iobs_no_scale_pks)^2+ (Error(scf)/Get(scale))^2 )/2 /Sqrt(M/Get(scale)); } Out_PRF(phasename) #else out phasename##_dys.mem append Out_String("\n# NREF2 fix to 0\n") Out_String(" 0\n") Out_String("# NREF3 need to count manually\n") Out_String(" 11\n") Out_String("# h k l") phase_out phasename##_dys.mem append load out_record out_fmt out_eqn { "\n%5.0f" = H; " %4.0f" = K; " %4.0f" = L; } #endif }
Out_PRF
The “Out_PRF” macro from below link generate a .prf preference file for Dysnomia to execute. For some reason, this TOPAS Wiki site does not display certain Out_String function, so I have to place it on my google drive:
https://drive.google.com/file/d/1wH5K6pJriHAAQyXCOpRfOQiowZXpKYGf/view?usp=sharing
Application Example: Working .inp to export .mem and .prf files
To use this function, please save the macros “Out_MEM”(on this page), “Out_PRF”(on this page), “Atomic_Number” and “sg_num” into your TOPAS' local.inc, or #include them in your .inp files.
Below example .inp file will be executed twice automatically.
The first run performs conventional Rietveld refinement and export information for the measured hkls.
The second run exports Miller indexes of unmeasured d-spacing reflections of higher spacing resolution, down to 0.7 Angstrom.
num_runs 2 'r_p 0 r_p_dash 0 'r_wp 0 r_wp_dash 0 'r_exp 0 r_exp_dash 0 'gof 0 'weighted_Durbin_Watson 0 #if (Run_Number == 0) RAW(corundum) do_errors CuKa5(0.001) ' Radiation used to measure the data out DMIN.txt Out(Lam /2/Sin(X2 Deg/2)) 'Export the min d_obs #else iters 0 yobs_eqn = 1; min 1 max 180 del 0.01 MoKa2(0.001) ' Dummy hard radiation to generate high Miller hkls prm DMIN = #include DMIN.txt; start_X = 2 ArcSin(Lam /2 /DMIN) Rad; 'calculate only the range between min d_obs to 0.7 Angstrom finish_X = 2 ArcSin(Lam /2 /0.7) Rad; 'The limit 0.7 Angstrom can be adapted according to your phase #endif Radius(173) LP_Factor(26.6) Full_Axial_Model(12, 15, 12, 4.6, 4.6) Slit_Width(0.3) Divergence(1) Absorption(@, 30) ZE(@,0) One_on_X(@, 1000) bkg @ 0 0 0 0 0 0 STR(R_-3_C) phase_name "Corundum" prm Total_e_in_Cell = Al_electrons + O_electrons;:0 ' Total Number of Electron in Unit Cell Trigonal(@ 4.75847, @ 12.99036) site Al num_posns 0 x 0 y 0 z @ 0.35228`_0.00003 occ Al 1 beq @ 0.29860`_0.00866 prm Al_electrons =Get(num_posns) * Atomic_Number("Al"); site O num_posns 0 x @ 0.30607`_0.00014 y 0 z 0.25 occ O 1 beq @ 0.16724`_0.01427 prm O_electrons =Get(num_posns) * Atomic_Number("O"); scale scf 0.00208062929`_5.482e-06 'name the scale factor as "scf" to export its error. CS_L(@, 274.753078`_7.43125129) Strain_L(@, 0.0166526397`_0.00141211878) r_bragg 3.76972174 Out_MEM(Corundum,"r-3c")
N.B.: the number of reflections “NREF1” and “NREF3” need be manually count and updated in the generated .mem file.
N.B.2: According to the Dysnomia examples, it seems do not need F_imaginary part for MEM analysis, therefore the imaginary part can be set to 0 in the generated .mem file.
N.B.3: Reflections of zero Fo(R) should be avoided, otherwise Dysnomia won't work.
If any user in our open TOPAS community has suggestion or idea, or bug report on these macros, please kindly let me know and I am happy to learn from you: tony.wang@qut.edu.au
Thanks for Dr. Koichi Momma's inspiring education in the IUCr Crystallographic Computing School (Melbourne, 2023). :)