all_macros
All User Macros
List below is all the macros in jsoe's library of user-contributed macros macros.inc August 2009.
'------------------------------------------------------------------------------------------------------------------------------------- 'Miscellaneous macros not in standard topas.inc ' 'Save the ones you need to your local.inc ' 'To get a listing highlight the word "Description" in jedit and hit alt-full_stop ' or highlight the word "macro" in jedit and hit alt-full_stop for a listing of macro names ' 'send contributions to john.evans@durham.ac.uk ' 'caveat emptor '------------------------------------------------------------------------------------------------------------------------------------- 'Description: write coordinates out in convenient min/max format with parameter names assigned 'Comment: useful for controlling a refinement and stopping atoms moving to far 'Contributed by: John Evans macro Out_min_max(file) { out file Out_String("\nmacro A1(param,val,val2) {x param val min = val2 - 0.1; max = val2 + 0.1; val_on_continue = val2;}") Out_String("\nmacro A2(param,val,val2) {y param val min = val2 - 0.1; max = val2 + 0.1; val_on_continue = val2;}") Out_String("\nmacro A3(param,val,val2) {z param val min = val2 - 0.1; max = val2 + 0.1; val_on_continue = val2;}") atom_out file append load out_record out_fmt out_eqn { "\n site %5s " = Get_From_String(Get(current_atom), site); " A1( x%s" = Get_From_String(Get(current_atom), site); ",%8.5f" = Get_From_String(Get(current_atom), x); " ,%8.5f" = Get_From_String(Get(current_atom), x); ") A2( y%s" = Get_From_String(Get(current_atom), site); ",%8.5f" = Get_From_String(Get(current_atom), y); " ,%8.5f" = Get_From_String(Get(current_atom), y); ") A3( z%s" = Get_From_String(Get(current_atom), site); ",%8.5f" = Get_From_String(Get(current_atom), z); " ,%8.5f" = Get_From_String(Get(current_atom), z); ") occ %5s" = Get_From_String(Get(current_atom), atom); " %6.4f" = Get_From_String(Get(current_atom), occ); " beq bvalue%s" = Get_From_String(Get(current_atom), site); " %6.4f" = Get_From_String(Get(current_atom), beq); } } 'Description: peak shape description for HRPD see isis tf14ls manuals for some description 'Comment: closer to fundamental parameters description for hrpd and better over large q range than other descriptions 'Contributed by: Bill David macro wifd_pkshape(two_theta,two_thetav,aprm,aprmv,tauf_2,tauf_2v,tauf_1,tauf_1v,tauf_0,tauf_0v,taus_0,taus_0v,taus_1,taus_1v,t_eff,t_effv,hhh,hhhv,hhh_0,hhh_0v) { local !two_theta two_thetav local !lam = 2 D_spacing Sin(0.00872664626 two_theta) ; prm aprm aprmv min 1.5 max 2.5 prm tauf_2 tauf_2v min 0.01 prm tauf_1 tauf_1v min 0.01 prm tauf_0 tauf_0v min 0.001 user_defined_convolution = X^aprm Exp(-X / (tauf_0 + tauf_1 lam + tauf_2 lam^2)); min 0 max = 20 aprm tauf_1 lam; prm taus_0 taus_0v min 0.001 prm taus_1 taus_1v min 0.001 prm t_eff t_effv min 90.0 local storage = Exp( -950 /(t_eff lam lam)) ; push_peak prm hhh hhhv min .001 prm hhh_0 hhh_0v min 0.001 hat = hhh_0 + hhh D_spacing; scale_top_peak = (1-storage); bring_2nd_peak_to_top hat = hhh_0 + hhh D_spacing; scale_top_peak = storage; exp_conv_const = -Ln(0.001) (taus_0 + lam taus_1); add_pop_1st_2nd_peak } 'Description: Bill David peak shape for GEM diffractometer 'Contributed by: Bill David at Denver topas meeting macro wifd_mic(two_theta,two_thetav,tspow,tspowv,tauf_0,tauf_0v,tauf_1,tauf_1v,taus_0,taus_0v,taus_1,taus_1v,t_eff,t_effv,hhh,hhhv,double_pulse,double_pulsev) { local !two_theta two_thetav prm tspow tspowv min 1.5 max 5.5 prm tauf_0 tauf_0v min 0.001 prm tauf_1 tauf_1v min 0.01 prm taus_0 taus_0v min 0.001 prm taus_1 taus_1v min 0.001 prm t_eff t_effv min 90.0 prm hhh hhhv min .001 prm double_pulse double_pulsev min 0.001 local !lam = 2 D_spacing Sin(0.00872664626 two_theta) ; user_defined_convolution = X^tspow Exp(-X / (tauf_0 + tauf_1 lam )); min 0 max = 10 (tauf_0 + tauf_1 lam ); local !storage = Exp( -950 /(t_eff lam^2)) hhh; push_peak hat = double_pulse ; scale_top_peak = (1-storage)/double_pulse; bring_2nd_peak_to_top exp_conv_const = -Ln(0.001) / (taus_0 + taus_1 / lam^2); scale_top_peak = storage/double_pulse; add_pop_1st_2nd_peak } 'Description: "old" gem tof peak shape 'Contributed by: John Evans macro gem_instrumental_peakshape( ,prma0, ,prma1, ,prmb0, ,prmb1) { push_peak exp_conv_const = prma0 + prma1 / D_spacing; bring_2nd_peak_to_top user_defined_convolution = prmb0 Exp(- prmb1 X) / D_spacing^4; min 0 max = -Ln(0.001) / prmb1; add_pop_1st_2nd_peak peak_buffer_step 1 'report_on } 'Description: sample contribution to tof peak shape 'Contributed by: John Evans macro tof_sample_peakshape(lor,lor_val,dsp,dsp_val,dspsq,dspsq_val) { prm dsp dsp_val del = 0.05 Val + 1; min 1 prm dspsq dspsq_val del = 0.05 Val + 1; min 0 peak_type pv pv_lor lor lor_val pv_fwhm = dsp D_spacing + dspsq D_spacing^2; } 'Description: Stephens peak shape broadening macros 'Contributed by: Peter Stephens, Robert Dinnebier, Andreas Leinweber 'An alternative approach to spherical harmonics for hkl dependent peak shapes by 'Peter Stephens (P.W. Stephens, J. Appl. Cryst. (1999) 32, 281-9) as coded in gsas. 'eta term allows mixture of Gauss/Lorentz broadening: ' 'As an example try: 'prm s400 11769.84126` 'prm s004 153.55044` 'prm s220 28029.32854` 'prm s202 -1067.03124` 'prm eta 0.52180` min 0 max 1 'Stephens_tetragonal(s400, s004, s220, s202, eta) macro Stephens_tetragonal(s400, s004, s220, s202, eta) { prm mhkl = Abs(S400 (H^4+ K^4)+ S004 L^4+ S220 H^2 K^2 + S202 (H^2 L^2 + K^2 L^2) ); prm pp = D_spacing^2 * Sqrt(Max(mhkl,0)) / 1000; gauss_fwhm = 1.8/3.1415927 pp (1-eta) Tan(Th) + 0.0001; lor_fwhm = 1.8/3.1415927 pp eta Tan(Th) + 0.0001; } macro Stephens_monoclinic(s400, s040, s004, s220, s202, s022, s301, s121, s103, eta) { prm mhkl = H^4 s400 + K^4 s040 + L^4 s004 + H^2 K^2 s220 + H^2 L^2 s202 + K^2 L^2 s022 + H K^2 L s121 + H L^3 s103 + H^3 L s301; prm pp = D_spacing^2 * Sqrt(Max(mhkl,0)) / 1000; gauss_fwhm = 1.8/3.1415927 pp (1-eta) Tan(Th) + 0.0001; lor_fwhm = 1.8/3.1415927 pp eta Tan(Th) + 0.0001; } macro Stephens_hexagonal(s400, s202, s004, eta) { prm mhkl = H^4 s400 + K^4 s400 + L^4 s004 + H^2 K^2 3 s400 + H^2 L^2 s202 + K^2 L^2 s202 + H K L^2 s202 + H^3 K 2 s400 + H K^3 2 s400; prm pp = D_spacing^2 * Sqrt(Max(mhkl,0)) / 1000; gauss_fwhm = 1.8/3.1415927 pp (1-eta) Tan(Th) + 0.0001; lor_fwhm = 1.8/3.1415927 pp eta Tan(Th) + 0.0001; } macro Stephens_orthorhombic(s400, s040, s004, s220, s202, s022, eta) { prm mhkl = H^4 s400 + K^4 s040 + L^4 s004 + H^2 K^2 s220 + H^2 L^2 s202 + K^2 L^2 s022; prm pp = D_spacing^2 * Sqrt(Max(mhkl,0)) / 1000; gauss_fwhm = 1.8/3.1415927 pp (1-eta) Tan(Th) + 0.0001; lor_fwhm = 1.8/3.1415927 pp eta Tan(Th) + 0.0001; } 'Description: Robust refinement 'Contributed by: Kevin H. Stone, Saul H. Lapidus and Peter W. Stephens 'Reference: J. Appl. Cryst. (2009). 42, 385–391; "Implementation and use of robust refinement in powder diffraction in the presence of impurities" macro Robust_refinement_xye { 'Rescale peaks according to robust refinement algorithm r_exp 4.390 prm test = Get(r_exp); prm N = (1/test)^2; prm !p0 =0.40007404; prm !p1 =-2.5949286; prm !p2 =4.3513542; prm !p3 =-1.7400101; prm !p4 =3.6140845 * 10^-1; prm !p5 =-4.5247609 * 10^-2; prm !p6 =3.5986364 * 10^-3; prm !p7 =-1.8328008 * 10^-4; prm !p8 =5.7937184 * 10^-6; prm !p9 =-1.035303 * 10^-7; prm !p10 =7.9903166 * 10^-10; prm t = ((Yobs - Ycalc)/SigmaYobs); prm testjohn = If( t < 0.8, (1/Max(SigmaYobs^2, 1))*N, If(t < 21, N*((((((((((p10*t + p9)*t + p8)*t + p7) *t + p6)*t + p5)*t + p4)*t + p3) *t + p2)*t + p1)*t +p0)/(Yobs - Ycalc)^2, N*(2.0131 * Ln(t) + 3.9183)/(Yobs - Ycalc)^2)); weighting = If( t < 0.8, (1/Max(SigmaYobs^2, 1))*N, If(t < 21, N*((((((((((p10*t + p9)*t + p8)*t + p7) *t + p6)*t + p5)*t + p4)*t + p3) *t + p2)*t + p1)*t +p0)/(Yobs - Ycalc)^2, N*(2.0131 * Ln(t) + 3.9183)/(Yobs - Ycalc)^2)); recal_weighting_on_iter } macro Robust_refinement_poisson { 'Rescale peaks according to robust refinement algorithm 'N.B. changed SigmaYobs to Yobs^0.5 r_exp 4.390 prm test = Get(r_exp); prm N = (1/test)^2; prm !p0 =0.40007404; prm !p1 =-2.5949286; prm !p2 =4.3513542; prm !p3 =-1.7400101; prm !p4 =3.6140845 * 10^-1; prm !p5 =-4.5247609 * 10^-2; prm !p6 =3.5986364 * 10^-3; prm !p7 =-1.8328008 * 10^-4; prm !p8 =5.7937184 * 10^-6; prm !p9 =-1.035303 * 10^-7; prm !p10 =7.9903166 * 10^-10; prm t = ((Yobs - Ycalc)/Yobs^0.5); prm testjohn = If( t < 0.8, (1/Max(Yobs, 1))*N, If(t < 21, N*((((((((((p10*t + p9)*t + p8)*t + p7) *t + p6)*t + p5)*t + p4)*t + p3) *t + p2)*t + p1)*t +p0)/(Yobs - Ycalc)^2, N*(2.0131 * Ln(t) + 3.9183)/(Yobs - Ycalc)^2)); weighting = If( t < 0.8, (1/Max(Yobs, 1))*N, If(t < 21, N*((((((((((p10*t + p9)*t + p8)*t + p7) *t + p6)*t + p5)*t + p4)*t + p3) *t + p2)*t + p1)*t +p0)/(Yobs - Ycalc)^2, N*(2.0131 * Ln(t) + 3.9183)/(Yobs - Ycalc)^2)); recal_weighting_on_iter } 'Description: ride H atoms in organic structure 'Contributed by: Alan Coelho macro H_ride(h_site, c_site, xv, yv, zv, beqcv) { site h_site x = Constant((xv)-Get(Find_Child(Get(site_recs), c_site), x)) + Get(Find_Child(Get(site_recs), c_site), x); y = Constant((yv)-Get(Find_Child(Get(site_recs), c_site), y)) + Get(Find_Child(Get(site_recs), c_site), y); z = Constant((zv)-Get(Find_Child(Get(site_recs), c_site), z)) + Get(Find_Child(Get(site_recs), c_site), z); occ H 1 beq beqcv } 'Description: Get the distance between two sites and report it in the .inp file 'Conributed by: John Evans macro Get_Distance(sites, c, d_calc) { #m_ifarg c "" #m_unique_not_refine c #m_endif sites_distance c load site_to_restrain { sites } prm = c; : d_calc } 'Description: remove positive definite limits on adps 'Comment: by default topas puts limits on values of uij - it's often more useful to know if something goes npd 'Contributed by: Alan Coelho macro adp_no_limits { move_to u11 min = Val - .05; max = Val + .05; move_to u22 min = Val - .05; max = Val + .05; move_to u33 min = Val - .05; max = Val + .05; move_to u12 min = Val - .05; max = Val + .05; move_to u13 min = Val - .05; max = Val + .05; move_to u23 min = Val - .05; max = Val + .05; } 'Description: output cif file with adps for crystalmaker 'Comment: removes a couple of default topas cif items that crystalmaker doesn't like reading so saves editing files 'Contributed by: John Evans macro Out_CIF_crystalmaker(file) {Out_CIF_crystalmaker_1(file) Out_CIF_crystalmaker_2(file)} macro Out_CIF_crystalmaker_1(file) { out file Out_String("\ndata_") Out(Get(phase_name), "\n_chemical_name_mineral ?%s?") Out(Get(a), "\n_cell_length_a %V") Out(Get(b), "\n_cell_length_b %V") Out(Get(c), "\n_cell_length_c %V") Out(Get(al), "\n_cell_angle_alpha %V") Out(Get(be), "\n_cell_angle_beta %V") Out(Get(ga), "\n_cell_angle_gamma %V") Out(Get(cell_volume), "\n_cell_volume %V") Out(Get(sp_grp_char), "\n_space_group %s") Out_String("\nloop_\n_symmetry_equiv_pos_as_xyz") Out(Get(sp_xyzs_txt), "%s") Out_String("\nloop_") Out_String("\n_atom_site_label") ' Out_String("\n_atom_site_type_symbol") ' Out_String("\n_atom_site_symmetry_multiplicity") Out_String("\n_atom_site_fract_x") Out_String("\n_atom_site_fract_y") Out_String("\n_atom_site_fract_z") Out_String("\n_atom_site_occupancy") Out_String("\n_atom_site_B_iso_or_equiv") atom_out file append load out_record out_fmt out_eqn { "\n%s" = Get_From_String(Get(current_atom), site); ' " %s" = Get_From_String(Get(current_atom), atom); ' " %3.0f" = Get_From_String(Get(current_atom), num_posns); " %V" = Get_From_String(Get(current_atom), x); " %V" = Get_From_String(Get(current_atom), y); " %V" = Get_From_String(Get(current_atom), z); " %V" = Get_From_String(Get(current_atom), occ); " %V" = Get_From_String(Get(current_atom), beq); } } macro Out_CIF_crystalmaker_2(file) { out file append Out_String("\nloop_") Out_String("\n_atom_site_aniso_label") ' Out_String("\n_atom_site_type_symbol") Out_String("\n_atom_site_aniso_U_11") Out_String("\n_atom_site_aniso_U_22") Out_String("\n_atom_site_aniso_U_33") Out_String("\n_atom_site_aniso_U_12") Out_String("\n_atom_site_aniso_U_13") Out_String("\n_atom_site_aniso_U_23") atom_out file append load out_record out_fmt out_eqn { "\n%s" = Get_From_String(Get(current_atom), site); ' " %s" = Get_From_String(Get(current_atom), atom); " %V" = Get_From_String(Get(current_atom), u11); " %V" = Get_From_String(Get(current_atom), u22); " %V" = Get_From_String(Get(current_atom), u33); " %V" = Get_From_String(Get(current_atom), u12); " %V" = Get_From_String(Get(current_atom), u13); " %V" = Get_From_String(Get(current_atom), u23); } } 'Description: output cif file for Diamond 'Why: outputs Biso in format that Diamond will import properly 'Contributed by: Pamela Whitfield macro Out_CIF_Diamond(file) { out file Out_String("\ndata_") Out(Get(phase_name), "\n_chemical_name_mineral %s") Out(Get(a), "\n_cell_length_a %V") Out(Get(b), "\n_cell_length_b %V") Out(Get(c), "\n_cell_length_c %V") Out(Get(al), "\n_cell_angle_alpha %V") Out(Get(be), "\n_cell_angle_beta %V") Out(Get(ga), "\n_cell_angle_gamma %V") Out(Get(cell_volume), "\n_cell_volume %V") Out(Get(sp_grp_char), "\n_symmetry_space_group_name_H-M %s") Out_String("\nloop_\n_symmetry_equiv_pos_as_xyz") Out(Get(sp_xyzs_txt), "%s") Out_String("\nloop_") Out_String("\n_atom_site_label") Out_String("\n_atom_site_type_symbol") Out_String("\n_atom_site_fract_x") Out_String("\n_atom_site_fract_y") Out_String("\n_atom_site_fract_z") Out_String("\n_atom_site_occupancy") Out_String("\n_atom_site_symmetry_multiplicity") Out_String("\n_atom_site_adp_type") Out_String("\n_atom_site_U_iso_or_equiv") atom_out file append load out_record out_fmt out_eqn { "\n%s" = Get_From_String(Get(current_atom), site); " %s" = Get_From_String(Get(current_atom), atom); " %V" = Get_From_String(Get(current_atom), x); " %V" = Get_From_String(Get(current_atom), y); " %V" = Get_From_String(Get(current_atom), z); " %V" = Get_From_String(Get(current_atom), occ); " %3.0f" = Get_From_String(Get(current_atom), num_posns); " %s" = "Biso"; " %V" = Get_From_String(Get(current_atom), beq); } } macro Out_CIF_ADPs_Diamond(file) { out file append Out_String("\nloop_") Out_String("\n_atom_site_aniso_label") Out_String("\n_atom_site_aniso_U_11") Out_String("\n_atom_site_aniso_U_22") Out_String("\n_atom_site_aniso_U_33") Out_String("\n_atom_site_aniso_U_12") Out_String("\n_atom_site_aniso_U_13") Out_String("\n_atom_site_aniso_U_23") atom_out file append load out_record out_fmt out_eqn { "\n%s" = Get_From_String(Get(current_atom), site); " %V" = Get_From_String(Get(current_atom), u11); " %V" = Get_From_String(Get(current_atom), u22); " %V" = Get_From_String(Get(current_atom), u33); " %V" = Get_From_String(Get(current_atom), u12); " %V" = Get_From_String(Get(current_atom), u13); " %V" = Get_From_String(Get(current_atom), u23); } } 'Description: generate dif file in uxd format for Bruker eva software 'Comment: lets you match up results of Rietveld refinement in eva 'Contributed by: John Evans macro Out_Dif(file) { out file Out_String("_D-I\n") phase_out file append load out_record out_fmt out_eqn { " %11.5f" = D_spacing; " %11.5f\n" = I_after_scale_pks; } } 'Description: produce hkl labels and plots to use in gnuplot 'Comment: lets you manipulate plots quickly using gnuplot command line functionality 'Contributed by: John Evans macro Out_gnuplot_labels(file) { out file Out_String("# put quotation marks round hkl labels; change yoffset value to move labels\n") Out_String("set nolabel\n") Out_String("yoffset=1\n") phase_out file append load out_record out_fmt out_eqn { "set label %3.0f" = H; " %3.0f" =K; " %3.0f" = L; " at %11.5f" = 2 57.2957795130823 Th; ", %11.5f * yoffset \n" = I_after_scale_pks; } } macro Out_gnuplot_tics(file) { phase_out file append load out_record out_fmt out_eqn { " %11.5f" = 2 57.2957795130823 Th; " %11.5f\n" = I_after_scale_pks; } } 'Description: write out coordinates for Atoms 'Contributed by: John Evans macro write_atoms(file) { out file 'append Out_String("\nTITL output from topas") Out(Get(sp_grp_char), "\nSPGP %s") Out(Get(a), "\nCELL %f") Out(Get(b), " %f") Out(Get(c), " %f") Out(Get(al), " %f") Out(Get(be), " %f") Out(Get(ga), " %f") Out_String("\nFIELDS LAB COO TFB") atom_out file append load out_record out_fmt out_eqn { "\n%-7s" = Get_From_String(Get(current_atom), site); " %9.5f" = Get_From_String(Get(current_atom), x); " %9.5f" = Get_From_String(Get(current_atom), y); " %9.5f" = Get_From_String(Get(current_atom), z); ' " %9.5f" = Get_From_String(Get(current_atom), occ); " \n%9.5f" = Get_From_String(Get(current_atom), beq); } } 'Description: write atoms .inp file with adps 'Contributed by: John Evans macro write_atoms_adp(file) { out file 'append Out_String("\nTITL output from topas") Out(Get(sp_grp_char), "\nSPGP %s") Out(Get(a), "\nCELL %f") Out(Get(b), " %f") Out(Get(c), " %f") Out(Get(al), " %f") Out(Get(be), " %f") Out(Get(ga), " %f") Out_String("\nFIELDS LAB COO TFU") atom_out file append load out_record out_fmt out_eqn { "\n%-7s" = Get_From_String(Get(current_atom), site); " %9.5f" = Get_From_String(Get(current_atom), x); " %9.5f" = Get_From_String(Get(current_atom), y); " %9.5f" = Get_From_String(Get(current_atom), z); ' " %9.5f" = Get_From_String(Get(current_atom), occ); " \n%9.5f" = Get_From_String(Get(current_atom), u11); " %9.5f" = Get_From_String(Get(current_atom), u22); " %9.5f" = Get_From_String(Get(current_atom), u33); " %9.5f" = Get_From_String(Get(current_atom), u12); " %9.5f" = Get_From_String(Get(current_atom), u13); " %9.5f" = Get_From_String(Get(current_atom), u23); } }
all_macros.txt · Last modified: 2022/11/03 15:08 by 127.0.0.1