The macros below come originally from Alex McLennan at Liverpool, with later input from Chris Collins and John Claridge. Only known issue is with difc in multibank time of flight refinements. Each bank can be output separately to get round this.
macro Out_General_CIF_test(file) { out file if Prm_There(cell_formula_units_Z) { } else { local !cell_formula_units_Z 1 } if Prm_There(phase_number) { } else { local !phase_number 1 } Out_String("data_overall") Out(Abs(Get(refine_ls_shift_on_su_max)), "\n_refine_ls_shift/su_max %3.4f") Out_String("\n_computing_structure_refinement TOPAS-V5") Out(Get(number_of_parameters), "\n_refine_ls_number_parameters %g") if Obj_There(scrysts) { Out((Get(gof)^2), "\n_refine_ls_goodness_of_fit_gt %1.5f") '' / Max((Sqrt(Yobs)),1) xdd_sum !denominator = Abs(Sqrt(Yobs)); xdd_sum !numerator = Abs(Abs(Sqrt(Yobs)) - Abs(Sqrt(Ycalc))); prm Unweighted_r_factor_based_F = numerator/ denominator; Out(Unweighted_r_factor_based_F, "\n_refine_ls_R_factor_gt %1.5f") Out(Get(r_wp), "\n_refine_ls_wR_factor_gt %1.5f") } else { Out_String("\n_pd_block_id \n") for xdds { Out(Get(xdd_path_name), "%s|") } Out_String("overall") Out((Get(gof)^2), "\n_refine_ls_goodness_of_fit_all %1.5f") Out(Get(r_p), "\n_pd_proc_ls_prof_R_factor %1.5f") Out(Get(r_wp), "\n_pd_proc_ls_prof_wR_factor %1.5f") Out(Get(r_exp), "\n_pd_proc_ls_prof_wR_expected %1.5f") Out_String("\nloop_ _pd_phase_block_id") for xdds { for strs { Out(phase_number, "\nphase_%V") Out(Get(sp_grp_char), "_%s") } } Out_String("\nloop_ _pd_block_diffractogram_id\n") for xdds { Out(Get(xdd_path_name), "%s\n") } } Out_String("\n#######End of overall data loop#######") if Obj_There(scrysts) { Out_CIFSTR(file) Out_FCFSXtal(file) } else { for xdds { Out_CIFSTR(file) } Out_CIFdata(file) } } macro Out_CIFSTR(file) { out file append for strs { if Obj_There(scrysts) { Out_String("\n#######Start of single crystal structure loop#######") } else { Out_String("\n#######Start of powder structure loop#######") Out(phase_number, "\ndata_phase_%V") Out(Get(sp_grp_char), "_%s") Out_String("\nloop_ _pd_block_diffractogram_id\n") Out(Get(xdd_path_name), "%s\n") Out_String("\n_cell_measurement_temperature") if Prm_There(Temperature) { Out(Get(Temperature), " %V") } else { Out_String(" 298.15") } } 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") if Obj_There(mag_sg) { Out(Get(mag_sg), "\n_space_group_IT_number %s") Out_String("\nloop_\n_space_group_symop_operation_xyz") Out_String("\n_magnetic_space_group_symop_operation_mxmymz") Out_String("\n_magnetic_space_group_symop_operation_timereversal") Out(Get(mag_sp_xyzs_txt), "%s") } else { Out(Get(sp_grp_char), "\n_space_group_name_H-M_alt %s") Out_String("\nloop_\n_space_group_symop_operation_xyz") Out(Get(sp_xyzs_txt), "%s") } Out_String("\nloop_") Out_String("\n_atom_type_symbol") Out_String("\n_atom_type_number_in_cell\n") atom_out file append load out_record out_fmt out_eqn { " %s" = Get_From_String(Get(current_atom), site); " %3.0f\n" = Get_From_String(Get(current_atom), num_posns); } out file append 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\n") atom_out file append load out_record out_fmt out_eqn { "%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\n" = Get_From_String(Get(current_atom), beq); } out file append local !density = ((1.6605402 Get(cell_mass)) / Get(cell_volume)); Out(density, "\n_exptl_crystal_density_diffrn %2.5f") Out(cell_formula_units_Z, "\n_cell_formula_units_Z %3.0f") local !chemical_formula_weight = Get(cell_mass)/cell_formula_units_Z;: 241.84175 Out(chemical_formula_weight, "\n_chemical_formula_weight %11.5f") '' if Obj_There(adps) { 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\n") atom_out file append load out_record out_fmt out_eqn { "%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\n" = Get_From_String(Get(current_atom), u23); } '' } if Obj_There(mag_sg) { out file append Out_String("\n\nloop_") Out_String("\n_magnetic_atom_site_label") Out_String("\n_magnetic_atom_site_moment_crystalaxis_mx") Out_String("\n_magnetic_atom_site_moment_crystalaxis_my") Out_String("\n_magnetic_atom_site_moment_crystalaxis_mz") atom_out file append load out_record out_fmt out_eqn { "\n%s" = Get_From_String(Get(current_atom), site); "%11.5f" = Get(a) Get_From_String(Get(current_atom), mlx); "%11.5f" = Get(b) Get_From_String(Get(current_atom), mly); "%11.5f" = Get(c) Get_From_String(Get(current_atom), mlz); } } else { } out file append Out(Get(cif_bonds_angles), "%s") Out_String("\n#######End of Structure loop#######") } } macro Out_CIFdata(file) { for xdds { out file append Out_String("\n#######Start of powder data loop#######") Out(Get(xdd_path_name), "\ndata_pxrd_%s") Out(Get(xdd_path_name), "\n_pd_block_id %s") Out_String("\nloop_") Out_String("\n_pd_phase_id") Out_String("\n_pd_phase_block_id") Out_String("\n_pd_phase_mass_%") for strs { Out(phase_number, "\n%V") Out(phase_number, " phase_%V") Out(Get(sp_grp_char), "_%s") Out(Get(weight_percent), " %1.2f") } if Obj_There(neutron) { } else { local !Mu = Get(mixture_MAC) Get(mixture_density_g_on_cm3); Out(Mu, "\n_exptl_absorpt_coefficient_mu %1.2f") } if And(Obj_There(neutron), Obj_There(pk_xo)) { } else { Out(Get(lam), "\n_diffrn_radiation_wavelength %1.5f") if Prm_There(LP_Factorval){ Out(LP_Factorval, "\n_diffrn_radiation_polarisn_norm %2.3f") } } if Obj_There(neutron) { Out_String("\n_diffrn_radiation_probe neutron") } else { Out_String("\n_diffrn_radiation_probe x-ray") } if Obj_There(scrysts) { Out((Get(gof)^2), "\n_refine_ls_goodness_of_fit_gt %1.5f") '' / Max((Sqrt(Yobs)),1) xdd_sum !denominator = Sqrt(Yobs); xdd_sum !numerator = Abs(Sqrt(Yobs) - Sqrt(Ycalc)); prm Unweighted_r_factor_based_F = numerator/ denominator; Out(Unweighted_r_factor_based_F, "\n_refine_ls_R_factor_gt %1.5f") Out(Get(r_wp), "\n_refine_ls_wR_factor_gt %1.5f") } else { Out((Get(gof)^2), "\n_refine_ls_goodness_of_fit_all %1.5f") Out(Get(r_p), "\n_pd_proc_ls_prof_R_factor %1.5f") Out(Get(r_wp), "\n_pd_proc_ls_prof_wR_factor %1.5f") Out(Get(r_exp), "\n_pd_proc_ls_prof_wR_expected %1.5f") } Out_String("\n_pd_calc_method Rietveld") if And(Obj_There(neutron), Obj_There(pk_xo)) { Out_String("\n_pd_meas_scan_method tof") Out(two_theta, "\n_pd_meas_2theta_fixed %1.5f", "(%.9g)") } else { Out(Get(start_X), "\n_pd_proc_2theta_range_min %11.5f") Out(Get(finish_X), "\n_pd_proc_2theta_range_max %11.5f") Out(Get(x_calculation_step), "\n_pd_proc_2theta_range_inc %11.5f") } Out_String("\nloop_") if And(Obj_There(neutron), Obj_There(pk_xo)) { Out_String("\n_pd_proc_point_id") Out_String("\n_pd_meas_time_of_flight") Out_String("\n_pd_proc_d_spacing") Out_String("\n_pd_proc_intensity_total") Out_String("\n_pd_proc_ls_weight") Out_String("\n_pd_calc_intensity_total\n") xdd_out file append load out_record out_fmt out_eqn { "%1.0f" = Xi; " %11.5f" = X; " %11.5f" = (1.997e-03/((difc/(505.56*Sin(Deg (two_theta/2))))*Sin((Deg (two_theta/2)))))*X; " %11.5f" = Yobs; "(%1.0f)" = SigmaYobs; " %11.5f" = If(Get(weighting) < 1, 1, Get(weighting)); " %11.5f\n" = Ycalc; } } else { Out_String("\n_pd_proc_point_id") Out_String("\n_pd_meas_2theta_scan") Out_String("\n_pd_proc_d_spacing") Out_String("\n_pd_proc_intensity_total") Out_String("\n_pd_calc_intensity_total") Out_String("\n_pd_proc_ls_weight\n") xdd_out file append load out_record out_fmt out_eqn { "%1.0f" = Xi; " %11.5f" = X; " %11.5f" = Lam / (2 Sin((Deg (X/2)))); " %11.5f" = Yobs; "(%1.0f)" = SigmaYobs; " %11.5f" = Ycalc; " %11.5f\n" = If(Get(weighting) < 1, 1, Get(weighting)); } } out file append Out_String("\n#######End of data loop#######") Out_String("\nloop_") Out_String("\n_refln_index_h") Out_String("\n_refln_index_k") Out_String("\n_refln_index_l") Out_String("\n_pd_refln_phase_id") Out_String("\n_refln_d_spacing") Out_String("\n_refln_F_squared_calc") Out_String("\n_refln_F_squared_meas") Out_String("\n_refln_F_squared_sigma") Out_String("\n_refln_include_status\n") for strs { phase_out file append load out_record out_fmt out_eqn { "%4.0f" = H; "%4.0f" = K; "%4.0f" = L; "%4.0f" = phase_number; " %11.5f" = D_spacing; " %11.5f" = I_no_scale_pks; " %11.5f" = Iobs_no_scale_pks; " %4.5f o\n" = Iobs_no_scale_pks_err; } } out file append Out_String("\n#######End of HKL loop#######") }