Advertisement
Guest User

Untitled

a guest
Dec 27th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 71.65 KB | None | 0 0
  1. #ifndef CIF_MACROS
  2. #define CIF_MACROS
  3. /*
  4. Written by Matthew Rowles.
  5.  
  6. The macros to be used by the user are:
  7. * Out_pdCIF,
  8. * Out_pdCIF_multi, and/or potentially,
  9. * Out_pdCIF_per_xdd.
  10.  
  11. To see their definitions, see the end of this file.
  12.  
  13. In general:
  14.  
  15. macro Out_pdCIF_per_xdd(ciffile) { Out_pdCIF_per_xdd(ciffile, "proc", =Get(bkg);) }
  16. macro Out_pdCIF_per_xdd(ciffile, data_type) { Out_pdCIF_per_xdd(ciffile, data_type, =Get(bkg);) }
  17. macro Out_pdCIF_per_xdd(ciffile, data_type, bkq_eqn) {
  18.  
  19. Out_pdCIF_per_xdd outputs diffraction data and crystal structure information for the xdd under which it is called.
  20.  
  21. The macro takes three arguments:
  22. ciffile: the name of the file you want to write to. The data is appended.
  23. data_type: "meas" - data as-measured; or "proc" - data has been processed before analysis
  24. bkg_eqn: an equation defining your background function so it can be ouput in the CIF
  25.  
  26. Two helper macros are given if you only wish to call the macro with one or two arguments. The remaining
  27. arguments are automaticaly set as shown.
  28.  
  29. ###############
  30.  
  31. macro Out_pdCIF(ciffile) { Out_pdCIF(ciffile, "proc", =Get(bkg);) }
  32. macro Out_pdCIF(ciffile, data_type) { Out_pdCIF(ciffile, data_type, =Get(bkg);) }
  33. macro Out_pdCIF(ciffile, data_type, bkq_eqn) { Out_pdCIF(ciffile, data_type, bkq_eqn, , ) }
  34. macro Out_pdCIF(ciffile, data_type, bkq_eqn, n, m) {
  35.  
  36. Out_pdCIF outputs diffraction data and crystal structure information for all xdds given in the macro call.
  37. It is meant for use in situations where each xdd is independent of the other xdds.
  38.  
  39. The macro takes five arguments:
  40. ciffile: the name of the file you want to write to. The data is appended.
  41. data_type: "meas" - data as-measured; or "proc" - data has been processed before analysis
  42. bkg_eqn: an equation defining your background function so it can be ouput in the CIF
  43. n: the inclusive number of the xdd at which to start the pdCIF output
  44. m: the inclusive number of the xdd at which to stop the pdCIF output
  45.  
  46. The macro with five arguments would be called rarely, and exits for completeness. Normally, the helper
  47. macro with three arguments would be called; this outputs all xdds and all strs in those xdds.
  48.  
  49. Three helper macros are given if you only wish to call the macro with one, two, or three arguments. The
  50. remaining arguments are automaticaly set as shown.
  51.  
  52. ###############
  53.  
  54. macro Out_pdCIF_multi(ciffile) { Out_pdCIF_multi(ciffile, "proc", =Get(bkg);) }
  55. macro Out_pdCIF_multi(ciffile, data_type) { Out_pdCIF_multi(ciffile, data_type, =Get(bkg);) }
  56. macro Out_pdCIF_multi(ciffile, data_type, bkg_eqn) { Out_pdCIF_multi(ciffile, data_type, bkg_eqn, 1, ) }
  57. macro Out_pdCIF_multi(ciffile, data_type, bkg_eqn, n, m) {
  58.  
  59. Out_pdCIF_multi outputs diffraction data and crystal structure information for all xdds given in the macro call.
  60. It is meant for use in situations where some xdds are dependent on other xdds. eg multi-bank tof refinements
  61.  
  62. The macro takes five arguments:
  63. ciffile: the name of the file you want to write to. The data is appended.
  64. data_type: "meas" - data as-measured; or "proc" - data has been processed before analysis
  65. bkg_eqn: an equation defining your background function so it can be ouput in the CIF
  66. n: the inclusive number of the xdd at which to start the pdCIF output
  67. m: the inclusive number of the xdd at which to stop the pdCIF output
  68.  
  69. The macro with five arguments would be called in a situation where there are many groups of xdds in a
  70. single inp file. The macro would be called as many times as there are groups, with the start and stop xdd
  71. numbers given in each macro call. It is assumed that each group of xdds is contiguous in the inp file.
  72. In there event of having only a single group in the inp file, the three-argument version can be used.
  73.  
  74. Three helper macros are given if you only wish to call the macro with one, two, or three arguments. The
  75. remaining arguments are automaticaly set as shown.
  76.  
  77. ###############
  78.  
  79.  
  80. To get maximum benefit, copy this file to your TOPAS directory and add
  81. the following line to your local.inc:
  82. #include cif.inc
  83.  
  84. For updates, check http://topas.dur.ac.uk/topaswiki/doku.php?id=out_pdcif
  85.  
  86. -----------
  87.  
  88. MIT License
  89.  
  90. Copyright (c) 2022 Matthew Rowles
  91.  
  92. Permission is hereby granted, free of charge, to any person obtaining a copy
  93. of this software and associated documentation files (the "Software"), to deal
  94. in the Software without restriction, including without limitation the rights
  95. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  96. copies of the Software, and to permit persons to whom the Software is
  97. furnished to do so, subject to the following conditions:
  98.  
  99. The above copyright notice and this permission notice shall be included in all
  100. copies or substantial portions of the Software.
  101.  
  102. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  103. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  104. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  105. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  106. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  107. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  108. SOFTWARE.
  109. */
  110.  
  111. '##############################################################'
  112. 'Helper macros'
  113. macro TOF_ED_CW(tof,ed,cw) {
  114. /*
  115. This macro allows you to choose between three different things depending
  116. on whether or not the data is TOF, EDXRD, or constant wavelength
  117. */
  118. if And(Obj_There(neutron), Or(Prm_There(pk_xo_exists), Obj_There(pk_xo))) { 'neutron TOF'
  119. tof
  120. } else if Obj_There(d_spacing_to_energy_in_eV_for_f1_f11) { 'energy-dispersive X-ray'
  121. ed
  122. } else { 'constant wavelength X-ray or neutron'
  123. cw
  124. }
  125. }
  126.  
  127. macro & d_spacing_from_TOF(& t0, & t1, & t2) {
  128. ' This macro calculates d spacing from TOF'
  129. (-t1 + Sqrt(t1^2 - 4 t2 (t0 - X))) / (2 t2)
  130. }
  131.  
  132. macro & d_spacing_from_EDXRD(& th2) { 'degrees'
  133. ' This macro calculates d spacing from EDXRD - th2 is the angle of the detector in degrees'
  134. 12398.41974 / ( 2 X Sin(th2 Deg_on_2)) ' X is eV'
  135. '= (h c / e) / (1x10^-10) -> eV per angstrom'
  136. }
  137.  
  138. macro n_to_m(n,m) {
  139. #m_ifarg n ""
  140. 'do nothing'
  141. #m_else
  142. #m_ifarg m ""
  143. 'do nothing'
  144. #m_else
  145. n## to ##m
  146. #m_endif
  147. #m_endif
  148. }
  149.  
  150. '##############################################################'
  151. ' Macros common to diffraction data and crystal structures'
  152. '##############################################################'
  153.  
  154. macro Out_CIF_newfile(ciffile) {
  155. 'Opens a file for appending to.'
  156. out ciffile append
  157. }
  158.  
  159. macro Out_CIF_section_break(comment) {
  160. 'Inserts a comment in the style of a section break'
  161. Out_String("\n#######\t")
  162. Out_String(comment)
  163. Out_String("\t#######")
  164. }
  165.  
  166. macro Out_CIF_datablock(blocknamebase, id) {
  167. /*
  168. Create the start of an entry in a CIF file. All CIF files must contain at least
  169. one datablock. The name must be unique.
  170.  
  171. blocknamebase: a string that you want to appear in the datablock name. No spaces!
  172. id: an identifier to be appended to the blocknamebase to ensure the
  173. datablock name is unique. No spaces!
  174. */
  175. Out_String("\ndata_")
  176. Out(blocknamebase, "%s")
  177. Out(id, "_%V")
  178. }
  179. macro Out_CIF_datablock_dataname {
  180. Out_String("\ndata_")
  181. }
  182.  
  183. macro Out_unique_phase_id(id) {
  184. if Prm_There(CIF_PHASE_BLOCK_ID) {
  185. Out(CIF_PHASE_BLOCK_ID, "%s")
  186. } else {
  187. Out(Get(phase_name), "%s")
  188. Out(id, "_%V")
  189. }
  190. }
  191.  
  192. macro Out_unique_diffractogram_id(id) {
  193. if Prm_There(CIF_DIFFRACTOGRAM_BLOCK_ID) {
  194. Out(CIF_DIFFRACTOGRAM_BLOCK_ID, "%s")
  195. } else {
  196. Out(Get(xdd_path_name), "%s")
  197. Out(id, "_%V")
  198. }
  199. }
  200.  
  201. macro Out_pdCIF_blockid(blockidbase, id) {
  202. /*
  203. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_block_id.html
  204. _pd_block_id
  205. Used to assign a unique character string to a block.
  206. Note that this code is not intended to be parsed; the
  207. concatenation of several strings is used in order to
  208. generate a string that can reasonably be expected to
  209. be unique.
  210.  
  211. Note: The pdCIF website for this dataname goes into extensive detail
  212. as to how this block_id is to be constructed. The implementation
  213. is this macro is extremely simplistic, and designed to be easily
  214. automated.
  215. */
  216. Out_pdCIF_blockid_dataname
  217. Out(blockidbase, "%s")
  218. Out(id, "_%V")
  219. }
  220. macro Out_pdCIF_blockid_dataname {
  221. Out_String("\n_pd_block_id\t")
  222. }
  223.  
  224.  
  225. macro Out_CIF_wavelength {
  226. /*
  227. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Idiffrn_radiation_wavelength.html
  228. _diffrn_radiation_wavelength
  229. The radiation wavelength in angstroms.
  230. */
  231. Out(Lam, "\n_diffrn_radiation_wavelength\t%.9f")
  232. }
  233.  
  234. macro Out_CIF_free_text(text) {
  235. 'Inserts a string into the CIF. Must conform to CIF standards'
  236. Out_String(text)
  237. }
  238. '##############################################################'
  239. ' Macros for diffraction data '
  240. '##############################################################'
  241.  
  242. macro Out_pdCIF_scan_method(method) {
  243. /*
  244. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_meas_scan_method.html
  245. _pd_meas_scan_method
  246. Code identifying the method for scanning reciprocal space.
  247. The designation 'fixed' should be used for measurements where
  248. film, a stationary position-sensitive or area detector
  249. or other non-moving detection mechanism is used to
  250. measure diffraction intensities.
  251.  
  252. the value of "method" you pass in must be one of:-
  253. step : step scan
  254. cont : continuous scan
  255. tof : time of flight
  256. disp : energy dispersive
  257. fixed: stationary detector
  258. */
  259. #m_ifarg method "" #m_else
  260. Out(method, "\n_pd_meas_scan_method\t%s")
  261. #m_endif
  262. }
  263.  
  264. macro Out_pdCIF_instr_special_details(goniotype) {
  265. /*
  266. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/index.html
  267. _pd_instr_special_details
  268. A brief description of the instrument giving
  269. details that cannot be given in other
  270. _pd_instr_ entries.
  271. */
  272. Out(goniotype, "\n_pd_instr_special_details\n;%s\n;")
  273. }
  274.  
  275. macro Out_pdCIF_datetime_initiated(datetime) {
  276. /*
  277. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_meas_datetime_initiated.html
  278. _pd_meas_datetime_initiated
  279. The date and time of the data-set measurement. Entries follow
  280. the standard CIF format 'yyyy-mm-ddThh:mm:ss+zz'. Use
  281. of seconds and a time zone is optional, but use of hours
  282. and minutes is strongly encouraged. Where possible, give the
  283. time when the measurement was started rather than when
  284. it was completed.
  285. */
  286. Out(datetime, "\n_pd_meas_datetime_initiated\t%s")
  287. }
  288.  
  289. macro Out_CIF_temperature(temp) {
  290. /*
  291. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Idiffrn_ambient_temperature.html
  292. _diffrn_ambient_temperature
  293. The mean temperature in kelvins at which the intensities
  294. were measured.
  295. */
  296. Out(temp, "\n_diffrn_ambient_temperature\t%V")
  297. }
  298.  
  299. macro Out_CIF_pressure(pres) {
  300. /*
  301. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Idiffrn_ambient_pressure.html
  302. _diffrn_ambient_pressure
  303. The mean hydrostatic pressure in kilopascals at which the
  304. intensities were measured.
  305. */
  306. Out(pres, "\n_diffrn_ambient_pressure\t%V")
  307. }
  308.  
  309. macro Out_pdCIF_2theta_fixed(th2) {
  310. /*
  311. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_meas_2theta_fixed.html
  312. _pd_meas_2theta_fixed
  313. The 2\q diffraction angle in degrees for measurements
  314. in a white-beam fixed-angle experiment.
  315. */
  316. Out(th2, "\n_pd_meas_2theta_fixed\t%s")
  317. }
  318.  
  319. macro Out_pdCIF_phase_block_id(phase_id, id) {
  320. /*
  321. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_phase_block_id.html
  322. _pd_phase_block_id
  323. A block ID code identifying the phase contributing to
  324. the diffraction peak. The data block containing the
  325. crystallographic information for this phase will be
  326. identified with a _pd_block_id code matching the
  327. code in _pd_phase_block_id.
  328.  
  329. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_phase_id.html
  330. _pd_phase_id
  331. A code for each crystal phase used to link with
  332. _pd_refln_phase_id.
  333.  
  334. _pd_phase_mass_%
  335. Per cent composition of the specified crystal phase
  336. expressed as the total mass of the component
  337. with respect to the total mass of the specimen.
  338. */
  339. Out_String("\nloop_")
  340. Out_String("\n\t_pd_phase_id")
  341. Out_String("\n\t_pd_phase_block_id")
  342. Out_String("\n\t_pd_phase_mass_%")
  343. for strs {
  344. Out_String("\n")
  345. Out(phase_id, "%V\t")
  346. Out_unique_phase_id(id)
  347. if Obj_There(spiked_mwp) {
  348. Out(Get(corrected_weight_percent), "\t%V")
  349. } else {
  350. Out(Get(weight_percent), "\t%V")
  351.  
  352. }
  353. }
  354. }
  355.  
  356. macro Out_CIF_Rfactors {
  357. /*
  358. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefine_ls_goodness_of_fit_all.html
  359. _refine_ls_goodness_of_fit_all
  360. The least-squares goodness-of-fit parameter S for all
  361. reflections after the final cycle of refinement.
  362. Ideally, account should be taken of parameters restrained
  363. in the least-squares refinement. See also
  364. _refine_ls_restrained_S_ definitions.
  365.  
  366. { sum { w [ Y(obs) - Y(calc) ]^2^ } }^1/2^
  367. S = { ----------------------------------- }
  368. { Nref - Nparam }
  369.  
  370. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_ls_prof_.html
  371. _pd_proc_ls_prof_R_factor
  372. _pd_proc_ls_prof_wR_factor
  373. _pd_proc_ls_prof_wR_expected
  374. Rietveld/profile fit R factors.
  375.  
  376. Note that the R factor computed for Rietveld refinements
  377. using the extracted reflection intensity values (often
  378. called the Rietveld or Bragg R factor, R~B~) is not properly
  379. a profile R factor. This R factor may be specified using
  380. _refine_ls_R_I_factor. (Some authors report
  381. _refine_ls_R_Fsqd_factor or _refine_ls_R_factor_all
  382. as the Rietveld or Bragg R factor. While it is appropriate
  383. to compute and report any or all of these R factors,
  384. the names "Rietveld or Bragg R factor" refer strictly to
  385. _refine_ls_R_I_factor.)
  386.  
  387. _pd_proc_ls_prof_R_factor, often called R~p~, is an
  388. unweighted fitness metric for the agreement between the
  389. observed and computed diffraction patterns.
  390. R~p~ = sum~i~ | I~obs~(i) - I~calc~(i) |
  391. / sum~i~ ( I~obs~(i) )
  392. _pd_proc_ls_prof_wR_factor, often called R~wp~, is a
  393. weighted fitness metric for the agreement between the
  394. observed and computed diffraction patterns.
  395. R~wp~ = SQRT {
  396. sum~i~ ( w(i) [ I~obs~(i) - I~calc~(i) ]^2^ )
  397. / sum~i~ ( w(i) [I~obs~(i)]^2^ ) }
  398.  
  399. _pd_proc_ls_prof_wR_expected, sometimes called the
  400. theoretical R~wp~ or R~exp~, is a weighted fitness metric for
  401. the statistical precision of the data set. For an idealized fit,
  402. where all deviations between the observed intensities and
  403. those computed from the model are due to statistical
  404. fluctuations, the observed R~wp~ should match the expected
  405. R factor. In reality, R~wp~ will always be higher than
  406. R~exp~.
  407. R~exp~ = SQRT {
  408. (n - p) / sum~i~ ( w(i) [I~obs~(i)]^2^ ) }
  409.  
  410. Note that in the above equations,
  411. w(i) is the weight for the ith data point (see
  412. _pd_proc_ls_weight).
  413. I~obs~(i) is the observed intensity for the ith data
  414. point, sometimes referred to as y~i~(obs) or
  415. y~oi~. (See _pd_meas_counts_total,
  416. _pd_meas_intensity_total or _pd_proc_intensity_total.)
  417. I~calc~(i) is the computed intensity for the ith data
  418. point with background and other corrections
  419. applied to match the scale of the observed data set,
  420. sometimes referred to as y~i~(calc) or
  421. y~ci~. (See _pd_calc_intensity_total.)
  422. n is the total number of data points (see
  423. _pd_proc_number_of_points) less the number of
  424. data points excluded from the refinement.
  425. p is the total number of refined parameters.
  426. */
  427. Out(Get(gof), "\n_refine_ls_goodness_of_fit_all\t%1.5f")
  428. Out(Get(r_p)/100, "\n_pd_proc_ls_prof_R_factor\t%1.5f")
  429. Out(Get(r_wp)/100, "\n_pd_proc_ls_prof_wR_factor\t%1.5f")
  430. Out(Get(r_exp)/100, "\n_pd_proc_ls_prof_wR_expected\t%1.5f")
  431. }
  432.  
  433. /*
  434. These next set of groups of three macros are for outputting constant-wavelength angle-dispersive data,
  435. time-of-flight neutron data, and energy-dispersive X-ray data.
  436.  
  437. meas denotes intensity measurements at the measurement point
  438. proc denotes intensity measurements that have been processed in some way at the measurement point
  439. */
  440. macro Out_pdCIF_angle_dispersive_measured_data(ciffile) {
  441. Out_pdCIF_angle_dispersive_data(ciffile, meas, =Get(bkg);)
  442. }
  443. macro Out_pdCIF_angle_dispersive_processed_data(ciffile) {
  444. Out_pdCIF_angle_dispersive_data(ciffile, proc, =Get(bkg);)
  445. }
  446. macro Out_pdCIF_angle_dispersive_data(ciffile, type, bkg_eqn) {
  447. /*
  448. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_meas_2theta_scan.html
  449. _pd_meas_2theta_scan
  450. 2\q diffraction angle (in degrees) for intensity
  451. points measured in a scanning method. The scan method used
  452. (e.g. continuous or step scan) should be specified in
  453. the item _pd_meas_scan_method. For fixed 2\q (white-beam)
  454. experiments, use _pd_meas_2theta_fixed. In the case of
  455. continuous-scan data sets, the 2\q value should be the
  456. value at the midpoint of the counting period. Associated
  457. with each _pd_meas_2theta_scan value will be
  458. _pd_meas_counts_ items. The 2\q values should
  459. not be corrected for nonlinearity,
  460. zero offset etc. Corrected values may be specified
  461. using _pd_proc_2theta_corrected.
  462.  
  463. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_meas_intensity_.html
  464. _pd_meas_intensity_total
  465. Intensity measurements at the measurement point (see
  466. the definition of _pd_meas_2theta_).
  467.  
  468. Use this entry for measurements where intensity
  469. values are not counts (use _pd_meas_counts_ for event-counting
  470. measurements where the standard uncertainty is
  471. estimated as the square root of the number of counts).
  472.  
  473. Corrections for background, detector dead time etc.,
  474. should not have been made to these values. Instead use
  475. _pd_proc_intensity_ for corrected diffractograms.
  476.  
  477. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_intensity_.html
  478. _pd_proc_intensity_total
  479. This contains intensity values for the
  480. processed diffractogram for each data point where
  481. background, normalization and other corrections have not
  482. been applied.
  483. Inclusion of s.u. values for these values is strongly recommended.
  484.  
  485. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_ls_weight.html
  486. _pd_proc_ls_weight
  487. Weight applied to each profile point. These values
  488. may be omitted if the weights are 1/u^2^, where
  489. u is the s.u. for the _pd_proc_intensity_net values.
  490.  
  491. A weight value of zero is used to indicate a data
  492. point not used for refinement (see
  493. _pd_proc_info_excluded_regions).
  494.  
  495. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_calc_intensity_.html
  496. _pd_calc_intensity_total
  497. Intensity values for a computed diffractogram at
  498. each angle setting. Values should be computed at the
  499. same locations as the processed diffractogram, and thus
  500. the numbers of points will be defined by
  501. _pd_proc_number_of_points and point positions may
  502. be defined using _pd_proc_2theta_range_ or
  503. _pd_proc_2theta_corrected.
  504.  
  505. Use _pd_calc_intensity_net if the computed diffractogram
  506. does not contain background or normalization corrections
  507. and thus is specified on the same scale as the
  508. _pd_proc_intensity_net values.
  509.  
  510. Use _pd_calc_intensity_total if the computed diffraction
  511. pattern includes background or normalization corrections
  512. (or both) and thus is specified on the same scale as the
  513. observed intensities (_pd_meas_counts_ or _pd_meas_intensity_).
  514.  
  515. If an observed pattern is included, _pd_calc_intensity_
  516. should be looped with either _pd_proc_intensity_net,
  517. _pd_meas_counts_ or _pd_meas_intensity_.
  518.  
  519. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_intensity_.html
  520. _pd_proc_intensity_bkg_calc
  521. This is intended to contain the
  522. background intensity for every data point where the
  523. background function has been fitted or estimated
  524.  
  525. ciffile - string. The name of the cif file you want to write to.
  526. bkg_eqn - topas equation. The equation you arre using for your background.
  527. If you are using the built in bkg, then write "=Get(bkg);" (without the "")
  528. */
  529. Out_CIF_newfile(ciffile)
  530. Out_String("\nloop_")
  531. Out_String("\n\t_pd_meas_2theta_scan")
  532. #if type == "meas";
  533. Out_String("\n\t_pd_meas_intensity_total")
  534. #else
  535. Out_String("\n\t_pd_proc_intensity_total")
  536. #endif
  537. Out_String("\n\t_pd_proc_ls_weight")
  538. Out_String("\n\t_pd_calc_intensity_total")
  539. #m_ifarg bkg_eqn ""
  540. xdd_out ciffile append
  541. load out_record out_fmt out_eqn {
  542. "\n%11.6f" = X;
  543. "\t%11.6f" = Yobs;
  544. "\t%11.6f" = Get(weighting);
  545. "\t%11.6f" = Ycalc;
  546. }
  547. #m_else
  548. Out_String("\n\t_pd_proc_intensity_bkg_calc")
  549. xdd_out ciffile append
  550. load out_record out_fmt out_eqn {
  551. "\n%11.6f" = X;
  552. "\t%11.6f" = Yobs;
  553. "\t%11.6f" = Get(weighting);
  554. "\t%11.6f" = Ycalc;
  555. "\t%11.6f" bkg_eqn
  556. }
  557. #m_endif
  558. }
  559.  
  560. macro Out_pdCIF_time_of_flight_measured_data(ciffile) {
  561. Out_pdCIF_time_of_flight_data(ciffile, meas, =Get(bkg);)
  562. }
  563. macro Out_pdCIF_time_of_flight_processed_data(ciffile) {
  564. Out_pdCIF_time_of_flight_data(ciffile, proc, =Get(bkg);)
  565. }
  566. macro Out_pdCIF_time_of_flight_data(ciffile, type, bkg_eqn) {
  567. /*
  568. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_meas_time_of_flight.html
  569. _pd_meas_time_of_flight
  570. Measured time in microseconds for time-of-flight neutron
  571. measurements. Note that the flight distance may be
  572. specified using _pd_instr_dist_ values.
  573.  
  574. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_d_spacing.html
  575. _pd_proc_d_spacing
  576. d-spacing corresponding to an intensity point
  577. from Braggs law, d = \l/(2 sin\q), in units of angstroms.
  578.  
  579. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_meas_intensity_.html
  580. _pd_meas_intensity_total
  581. Intensity measurements at the measurement point (see
  582. the definition of _pd_meas_2theta_).
  583.  
  584. Use this entry for measurements where intensity
  585. values are not counts (use _pd_meas_counts_ for event-counting
  586. measurements where the standard uncertainty is
  587. estimated as the square root of the number of counts).
  588.  
  589. Corrections for background, detector dead time etc.,
  590. should not have been made to these values. Instead use
  591. _pd_proc_intensity_ for corrected diffractograms.
  592.  
  593. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_intensity_.html
  594. _pd_proc_intensity_total
  595. This contains intensity values for the
  596. processed diffractogram for each data point where
  597. background, normalization and other corrections have not
  598. been applied.
  599. Inclusion of s.u. values for these values is strongly recommended.
  600.  
  601. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_ls_weight.html
  602. _pd_proc_ls_weight
  603. Weight applied to each profile point. These values
  604. may be omitted if the weights are 1/u^2^, where
  605. u is the s.u. for the _pd_proc_intensity_net values.
  606.  
  607. A weight value of zero is used to indicate a data
  608. point not used for refinement (see
  609. _pd_proc_info_excluded_regions).
  610.  
  611. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_calc_intensity_.html
  612. _pd_calc_intensity_total
  613. Intensity values for a computed diffractogram at
  614. each angle setting. Values should be computed at the
  615. same locations as the processed diffractogram, and thus
  616. the numbers of points will be defined by
  617. _pd_proc_number_of_points and point positions may
  618. be defined using _pd_proc_2theta_range_ or
  619. _pd_proc_2theta_corrected.
  620.  
  621. Use _pd_calc_intensity_net if the computed diffractogram
  622. does not contain background or normalization corrections
  623. and thus is specified on the same scale as the
  624. _pd_proc_intensity_net values.
  625.  
  626. Use _pd_calc_intensity_total if the computed diffraction
  627. pattern includes background or normalization corrections
  628. (or both) and thus is specified on the same scale as the
  629. observed intensities (_pd_meas_counts_ or _pd_meas_intensity_).
  630.  
  631. If an observed pattern is included, _pd_calc_intensity_
  632. should be looped with either _pd_proc_intensity_net,
  633. _pd_meas_counts_ or _pd_meas_intensity_.
  634.  
  635. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_intensity_.html
  636. _pd_proc_intensity_bkg_calc
  637. This is intended to contain the
  638. background intensity for every data point where the
  639. background function has been fitted or estimated
  640.  
  641. */
  642. Out_CIF_newfile(ciffile)
  643. Out_String("\nloop_")
  644. Out_String("\n\t_pd_meas_time_of_flight")
  645. Out_String("\n\t_pd_proc_d_spacing")
  646. #if type == "meas";
  647. Out_String("\n\t_pd_meas_intensity_total")
  648. #else
  649. Out_String("\n\t_pd_proc_intensity_total")
  650. #endif
  651. Out_String("\n\t_pd_proc_ls_weight")
  652. Out_String("\n\t_pd_calc_intensity_total")
  653. #m_ifarg bkg_eqn ""
  654. xdd_out ciffile append
  655. load out_record out_fmt out_eqn {
  656. "\n%11.6f" = X;
  657. "\t%11.6f" = d_spacing_from_TOF(CIF_t0, CIF_t1, CIF_t2);
  658. "\t%11.6f" = Yobs;
  659. "\t%11.6f" = Get(weighting);
  660. "\t%11.6f" = Ycalc;
  661. }
  662. #m_else
  663. Out_String("\n\t_pd_proc_intensity_bkg_calc")
  664. xdd_out ciffile append
  665. load out_record out_fmt out_eqn {
  666. "\n%11.6f" = X;
  667. "\t%11.6f" = d_spacing_from_TOF(t0, t1, t2);
  668. "\t%11.6f" = Yobs;
  669. "\t%11.6f" = Get(weighting);
  670. "\t%11.6f" = Ycalc;
  671. "\t%11.6f" bkg_eqn
  672. }
  673. #m_endif
  674. }
  675.  
  676.  
  677. macro Out_pdCIF_energy_dispersive_measured_data {
  678. Out_pdCIF_energy_dispersive_data(meas, =Get(bkg);)
  679. }
  680. macro Out_pdCIF_energy_dispersive_processed_data {
  681. Out_pdCIF_energy_dispersive_data(proc, =Get(bkg);)
  682. }
  683. macro Out_pdCIF_energy_dispersive_data(ciffile, type, bkg_eqn) {
  684. /*
  685. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_energy_.html
  686. _pd_proc_energy_incident
  687. Incident energy in electronvolts of the source computed
  688. from secondary calibration information (time-of-flight
  689. and synchrotron data).
  690.  
  691. Detection energy in electronvolts selected by the analyser,
  692. if not the same as the incident energy (triple-axis or
  693. energy-dispersive data). This may be a single value or may
  694. vary for each data point (triple-axis and time-of-flight data).
  695.  
  696. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_d_spacing.html
  697. _pd_proc_d_spacing
  698. d-spacing corresponding to an intensity point
  699. from Braggs law, d = \l/(2 sin\q), in units of angstroms.
  700.  
  701. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_meas_intensity_.html
  702. _pd_meas_intensity_total
  703. Intensity measurements at the measurement point (see
  704. the definition of _pd_meas_2theta_).
  705.  
  706. Use this entry for measurements where intensity
  707. values are not counts (use _pd_meas_counts_ for event-counting
  708. measurements where the standard uncertainty is
  709. estimated as the square root of the number of counts).
  710.  
  711. Corrections for background, detector dead time etc.,
  712. should not have been made to these values. Instead use
  713. _pd_proc_intensity_ for corrected diffractograms.
  714.  
  715. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_intensity_.html
  716. _pd_proc_intensity_total
  717. This contains intensity values for the
  718. processed diffractogram for each data point where
  719. background, normalization and other corrections have not
  720. been applied.
  721. Inclusion of s.u. values for these values is strongly recommended.
  722.  
  723. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_ls_weight.html
  724. _pd_proc_ls_weight
  725. Weight applied to each profile point. These values
  726. may be omitted if the weights are 1/u^2^, where
  727. u is the s.u. for the _pd_proc_intensity_net values.
  728.  
  729. A weight value of zero is used to indicate a data
  730. point not used for refinement (see
  731. _pd_proc_info_excluded_regions).
  732.  
  733. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_calc_intensity_.html
  734. _pd_calc_intensity_total
  735. Intensity values for a computed diffractogram at
  736. each angle setting. Values should be computed at the
  737. same locations as the processed diffractogram, and thus
  738. the numbers of points will be defined by
  739. _pd_proc_number_of_points and point positions may
  740. be defined using _pd_proc_2theta_range_ or
  741. _pd_proc_2theta_corrected.
  742.  
  743. Use _pd_calc_intensity_net if the computed diffractogram
  744. does not contain background or normalization corrections
  745. and thus is specified on the same scale as the
  746. _pd_proc_intensity_net values.
  747.  
  748. Use _pd_calc_intensity_total if the computed diffraction
  749. pattern includes background or normalization corrections
  750. (or both) and thus is specified on the same scale as the
  751. observed intensities (_pd_meas_counts_ or _pd_meas_intensity_).
  752.  
  753. If an observed pattern is included, _pd_calc_intensity_
  754. should be looped with either _pd_proc_intensity_net,
  755. _pd_meas_counts_ or _pd_meas_intensity_.
  756.  
  757. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_proc_intensity_.html
  758. _pd_proc_intensity_bkg_calc
  759. This is intended to contain the
  760. background intensity for every data point where the
  761. background function has been fitted or estimated
  762.  
  763. */
  764. Out_CIF_newfile(ciffile)
  765. Out_String("\nloop_")
  766. Out_String("\n\t_pd_proc_energy_incident")
  767. Out_String("\n\t_pd_proc_d_spacing")
  768. #if type == "meas";
  769. Out_String("\n\t_pd_meas_intensity_total")
  770. #else
  771. Out_String("\n\t_pd_proc_intensity_total")
  772. #endif
  773. Out_String("\n\t_pd_proc_ls_weight")
  774. Out_String("\n\t_pd_calc_intensity_total")
  775. #m_ifarg bkg_eqn ""
  776. xdd_out ciffile append
  777. load out_record out_fmt out_eqn {
  778. "\n%11.6f" = X;
  779. "\t%11.6f" = d_spacing_from_EDXRD(CIF_TH2_FIXED);
  780. "\t%11.6f" = Yobs;
  781. "\t%11.6f" = Get(weighting);
  782. "\t%11.6f" = Ycalc;
  783. }
  784. #m_else
  785. Out_String("\n\t_pd_proc_intensity_bkg_calc")
  786. xdd_out ciffile append
  787. load out_record out_fmt out_eqn {
  788. "\n%11.6f" = X;
  789. "\t%11.6f" = d_spacing_from_EDXRD(CIF_TH2_FIXED);
  790. "\t%11.6f" = Yobs;
  791. "\t%11.6f" = Get(weighting);
  792. "\t%11.6f" = Ycalc;
  793. "\t%11.6f" bkg_eqn
  794. }
  795. #m_endif
  796. }
  797.  
  798. macro Out_pdCIF_hkls_header(ciffile) {
  799. /*
  800. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_index_.html
  801. _refln_index_h
  802. _refln_index_k
  803. _refln_index_l
  804. Miller indices of the reflection. The values of the Miller
  805. indices in the REFLN category must correspond to the cell
  806. defined by the cell lengths and cell angles in the CELL category.
  807.  
  808. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_d_spacing.html
  809. _refln_d_spacing
  810. The d spacing in angstroms for this reflection. This is related
  811. to the (sin theta)/lambda value by the expression
  812. _refln_d_spacing = 2/(_refln_sint/lambda)
  813.  
  814. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_F_squared_.html
  815. _refln_F_squared_calc
  816. _refln_F_squared_meas
  817. Calculated, measured and estimated standard uncertainty (derived
  818. from measurement) of the squared structure factors (in electrons
  819. squared for X-ray diffraction).
  820. */
  821. Out_CIF_newfile(ciffile)
  822. Out_String("\nloop_")
  823. Out_String("\n\t_refln_index_h")
  824. Out_String("\n\t_refln_index_k")
  825. Out_String("\n\t_refln_index_l")
  826. Out_String("\n\t_pd_refln_phase_id")
  827. Out_String("\n\t_refln_d_spacing")
  828. Out_String("\n\t_refln_F_squared_calc")
  829. Out_String("\n\t_refln_F_squared_meas")
  830. }
  831. macro Out_pdCIF_hkls(ciffile, phase_id) {
  832. /*
  833. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_index_.html
  834. _refln_index_h
  835. _refln_index_k
  836. _refln_index_l
  837. Miller indices of the reflection. The values of the Miller
  838. indices in the REFLN category must correspond to the cell
  839. defined by the cell lengths and cell angles in the CELL category.
  840.  
  841. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_d_spacing.html
  842. _refln_d_spacing
  843. The d spacing in angstroms for this reflection. This is related
  844. to the (sin theta)/lambda value by the expression
  845. _refln_d_spacing = 2/(_refln_sint/lambda)
  846.  
  847. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_F_squared_.html
  848. _refln_F_squared_calc
  849. _refln_F_squared_meas
  850. Calculated, measured and estimated standard uncertainty (derived
  851. from measurement) of the squared structure factors (in electrons
  852. squared for X-ray diffraction).
  853. */
  854. for strs {
  855. Out_CIF_newfile(ciffile)
  856. phase_out ciffile append
  857. load out_record out_fmt out_eqn {
  858. "\n%4.0f" = H;
  859. "\t%4.0f" = K;
  860. "\t%4.0f" = L;
  861. "\t%V" = phase_id;
  862. "\t%11.6f" = D_spacing;
  863. "\t%12.6f" = I_no_scale_pks;
  864. "\t%12.6f" = Iobs_no_scale_pks;
  865. }
  866. }
  867. }
  868.  
  869.  
  870. '############################################################## '
  871. ' Macros for crystal structures '
  872. '############################################################## '
  873.  
  874.  
  875. macro Out_pdCIF_diffractogramid(diffractogramidbase, id) {
  876. /*
  877. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_block_diffractogram_id.html
  878. _pd_block_diffractogram_id
  879. A block ID code (see _pd_block_id) that identifies
  880. diffraction data contained in a data block other
  881. than the current block. This will occur most frequently
  882. when more than one set of diffraction data
  883. is used for a structure determination. The data
  884. block containing the diffraction data will contain
  885. a _pd_block_id code matching the code in
  886. _pd_block_diffractogram_id.
  887. */
  888. Out_pdCIF_diffractogramid_dataname
  889. Out(diffractogramidbase, "%s")
  890. Out(id, "_%V")
  891. }
  892. macro Out_pdCIF_diffractogramid_dataname {
  893. Out_String("\n_pd_block_diffractogram_id\t")
  894. }
  895. macro Out_pdCIF_phase_name {
  896. /*
  897. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_pd.dic/Ipd_phase_name.html
  898. _pd_phase_name
  899. The name of the crystal phase.
  900. */
  901. Out(Get(phase_name), "\n_pd_phase_name\n;%s\n;")
  902. }
  903.  
  904. macro Out_CIF_unit_cell_prms {
  905. /*
  906. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Icell_length_.html
  907. _cell_length_a
  908. _cell_length_b
  909. _cell_length_c
  910. Unit-cell lengths in angstroms corresponding to the structure
  911. reported. The values of _refln_index_h, *_k, *_l must
  912. correspond to the cell defined by these values and _cell_angle_
  913. values.
  914.  
  915. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Icell_angle_.html
  916. _cell_angle_alpha
  917. _cell_angle_beta
  918. _cell_angle_gamma
  919. Unit-cell angles of the reported structure in degrees.
  920. The values of _refln_index_h, *_k, *_l must correspond to the
  921. cell defined by these values and _cell_length_a, *_b and *_c.
  922.  
  923. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Icell_volume.html
  924. _cell_volume
  925. Cell volume V in angstroms cubed
  926. */
  927. Out(Get(a), "\n_cell_length_a %V")
  928. Out(Get(b), "\n_cell_length_b %V")
  929. Out(Get(c), "\n_cell_length_c %V")
  930. Out(Get(al), "\n_cell_angle_alpha %V")
  931. Out(Get(be), "\n_cell_angle_beta %V")
  932. Out(Get(ga), "\n_cell_angle_gamma %V")
  933. Out(Get(cell_volume), "\n_cell_volume %V")
  934. }
  935.  
  936. macro Out_CIF_Z_molecular_weight(Z) {
  937. /*
  938. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Icell_formula_units_Z.html
  939. _cell_formula_units_Z
  940. The number of the formula units in the unit cell as specified
  941. by _chemical_formula_structural, _chemical_formula_moiety or
  942. _chemical_formula_sum.
  943.  
  944. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ichemical_formula_weight.html
  945. _chemical_formula_weight
  946. Formula mass in daltons. This mass should correspond to the
  947. formulae given under _chemical_formula_structural, *_iupac,
  948. *_moiety or *_sum and, together with the Z value and cell
  949. parameters, should yield the density given as
  950. _exptl_crystal_density_diffrn.
  951. */
  952. local #m_unique !formula_weight_for_CIF_output = Get(cell_mass) / Z;
  953. Out(Z, "\n_cell_formula_units_Z\t%.0f")
  954. Out(formula_weight_for_CIF_output, "\n_chemical_formula_weight\t%V")
  955. }
  956.  
  957. macro Out_CIF_chemical_formula(formula) {
  958. /*
  959. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ichemical_formula_sum.html
  960. _chemical_formula_sum
  961. See the _chemical_formula_[] category description for the rules
  962. for writing chemical formulae in which all discrete bonded
  963. residues and ions are summed over the constituent elements,
  964. following the ordering given in general rule (5) in the
  965. _chemical_formula_[] category description. Parentheses are not
  966. normally used.
  967.  
  968. example
  969. 'C18 H19 N7 O8 S'
  970.  
  971. This will need manual editing, as TOPAS cannot output quotation marks.
  972. */
  973. Out(formula, "\n_chemical_formula_sum\t%s")
  974. }
  975.  
  976. macro Out_CIF_diffrn_measurement_device_type(goniotype) {
  977. /*
  978. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Idiffrn_measurement_device_type.html_cell_formula_units_Z
  979. _diffrn_measurement_device_type
  980. The make, model or name of the measurement device
  981. (goniometer) used.
  982. */
  983. Out(goniotype, "\n_diffrn_measurement_device_type\t%s")
  984. }
  985.  
  986. macro Out_CIF_space_group_crystal_system(system) {
  987. /*
  988. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ispace_group_crystal_system.html
  989. _space_group_crystal_system
  990. The name of the system of geometric crystal classes of space
  991. groups (crystal system) to which the space group belongs.
  992. Note that rhombohedral space groups belong to the
  993. trigonal system.
  994.  
  995. triclinic
  996. monoclinic
  997. orthorhombic
  998. tetragonal
  999. trigonal
  1000. hexagonal
  1001. cubic
  1002. */
  1003. Out(system, "\n_space_group_crystal_system\t%s")
  1004. }
  1005.  
  1006. macro Out_CIF_minmax_theta {
  1007. /*
  1008. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Icell_measurement_theta_.html
  1009. _cell_measurement_theta_min
  1010. _cell_measurement_theta_max
  1011. The maximum and minimum theta angles of reflections
  1012. used to measure the unit cell in degrees.
  1013. */
  1014. Out((X1/2), "\n_cell_measurement_theta_min\t%V")
  1015. Out((X2/2), "\n_cell_measurement_theta_max\t%V")
  1016. }
  1017.  
  1018. macro Out_CIF_density {
  1019. /*
  1020. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iexptl_crystal_density_diffrn.html
  1021. _exptl_crystal_density_diffrn
  1022. Density values calculated from the crystal cell and contents. The
  1023. units are megagrams per cubic metre (grams per cubic centimetre).
  1024. */
  1025. local #m_unique !density_only_for_CIF_output = (1.6605402 Get(cell_mass)) / Get(cell_volume);
  1026. Out(density_only_for_CIF_output, "\n_exptl_crystal_density_diffrn\t%V")
  1027. }
  1028.  
  1029. macro Out_CIF_absorption {
  1030. /*
  1031. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iexptl_absorpt_coefficient_mu.html
  1032. _exptl_absorpt_coefficient_mu
  1033. The absorption coefficient mu in reciprocal millimetres
  1034. calculated from the atomic content of the cell, the density and
  1035. the radiation wavelength.
  1036. */
  1037. local #m_unique !density_for_CIF_output = ((1.6605402 Get(cell_mass)) / Get(cell_volume));
  1038. local #m_unique !LAC_for_CIF_output = Get(phase_MAC) density_for_CIF_output / 10;
  1039. Out(LAC_for_CIF_output, "\n_exptl_absorpt_coefficient_mu\t%V")
  1040. }
  1041.  
  1042.  
  1043. macro Out_CIF_cell_temperature(temp) {
  1044. /*
  1045. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Icell_measurement_temperature.html
  1046. _cell_measurement_temperature\
  1047. The temperature in kelvins at which the unit-cell parameters
  1048. were measured (not the temperature of synthesis).
  1049. */
  1050. Out(temp, "\n_cell_measurement_temperature\t%V")
  1051. Out_CIF_temperature(temp)
  1052. }
  1053. macro Out_CIF_cell_pressure(pres) {
  1054. /*
  1055. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Icell_measurement_pressure.html
  1056. _cell_measurement_pressure
  1057. The pressure in kilopascals at which the unit-cell parameters
  1058. were measured (not the pressure at which the sample was
  1059. synthesized).
  1060. */
  1061. Out(pres, "\n_cell_measurement_pressure\t%V")
  1062. Out_CIF_pressure(pres)
  1063. }
  1064.  
  1065. macro Out_CIF_space_group_with_id {
  1066. /*
  1067. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ispace_group_name_H-M_alt.html
  1068. _space_group_name_H-M_alt
  1069. _space_group_name_H-M_alt allows any Hermann-Mauguin symbol
  1070. to be given. The way in which this item is used is determined
  1071. by the user and in general is not intended to be interpreted by
  1072. computer. It may, for example, be used to give one of the
  1073. extended Hermann-Mauguin symbols given in Table 4.3.2.1 of
  1074. International Tables for Crystallography Vol. A (2002) or
  1075. a Hermann-Mauguin symbol for a conventional or unconventional
  1076. setting.
  1077.  
  1078. Each component of the space-group name is separated by a
  1079. space or an underscore. Subscripts should appear without special
  1080. symbols. Bars should be given as negative signs before the
  1081. numbers to which they apply.
  1082.  
  1083. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ispace_group_symop_id.html
  1084. _space_group_symop_id
  1085. An arbitrary identifier that uniquely labels each symmetry
  1086. operation in the list.
  1087.  
  1088. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ispace_group_symop_operation_xyz.html
  1089. _space_group_symop_operation_xyz
  1090. A parsable string giving one of the symmetry operations of the
  1091. space group in algebraic form.
  1092.  
  1093. */
  1094. Out(Get(sp_grp_char), "\n_space_group_name_H-M_alt\n;%s\n;")
  1095. Out_String("\nloop_\n\t_space_group_symop_id\n\t_space_group_symop_operation_xyz")
  1096. Out(Get(sp_xyzs_txt_with_id), "%s")
  1097. }
  1098. macro Out_CIF_space_group_without_id {
  1099. /*
  1100. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ispace_group_name_H-M_alt.html
  1101. _space_group_name_H-M_alt
  1102. _space_group_name_H-M_alt allows any Hermann-Mauguin symbol
  1103. to be given. The way in which this item is used is determined
  1104. by the user and in general is not intended to be interpreted by
  1105. computer. It may, for example, be used to give one of the
  1106. extended Hermann-Mauguin symbols given in Table 4.3.2.1 of
  1107. International Tables for Crystallography Vol. A (2002) or
  1108. a Hermann-Mauguin symbol for a conventional or unconventional
  1109. setting.
  1110.  
  1111. Each component of the space-group name is separated by a
  1112. space or an underscore. Subscripts should appear without special
  1113. symbols. Bars should be given as negative signs before the
  1114. numbers to which they apply.
  1115.  
  1116. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ispace_group_symop_operation_xyz.html
  1117. _space_group_symop_operation_xyz
  1118. A parsable string giving one of the symmetry operations of the
  1119. space group in algebraic form.
  1120.  
  1121. */
  1122. Out(Get(sp_grp_char), "\n_space_group_name_H-M_alt\n;%s\n;")
  1123. Out_String("\nloop_\n\t_space_group_symop_operation_xyz")
  1124. Out(Get(sp_xyzs_txt), "%s")
  1125. }
  1126.  
  1127. macro Out_CIF_atom_coords(ciffile) {
  1128. /*
  1129. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_label.html
  1130. _atom_site_label
  1131. The _atom_site_label is a unique identifier for a particular site
  1132. in the crystal. This code is made up of a sequence of up to seven
  1133. components, _atom_site_label_component_0 to *_6, which may be
  1134. specified as separate data items. Component 0 usually matches one
  1135. of the specified _atom_type_symbol codes. This is not mandatory
  1136. if an _atom_site_type_symbol item is included in the atom-site
  1137. list. The _atom_site_type_symbol always takes precedence over
  1138. an _atom_site_label in the identification of the atom type.
  1139.  
  1140. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_type_symbol.html
  1141. _atom_site_type_symbol
  1142. A code to identify the atom species (singular or plural)
  1143. occupying this site.
  1144.  
  1145. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_site_symmetry_multiplicity.html
  1146. _atom_site_site_symmetry_multiplicity
  1147. The number of different sites that are generated by the
  1148. application of the space-group symmetry to the
  1149. coordinates given for this site. It is equal to the
  1150. multiplicity given for this Wyckoff site
  1151. in International Tables for Crystallography Vol. A (2002).
  1152.  
  1153. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_fract_.html
  1154. _atom_site_fract_x
  1155. _atom_site_fract_y
  1156. _atom_site_fract_z
  1157. Atom-site coordinates as fractions of the _cell_length_ values.
  1158.  
  1159. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_occupancy.html
  1160. _atom_site_occupancy
  1161. The fraction of the atom type present at this site.
  1162. The sum of the occupancies of all the atom types at this site
  1163. may not significantly exceed 1.0 unless it is a dummy site.
  1164.  
  1165. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_B_iso_or_equiv.html
  1166. _atom_site_B_iso_or_equiv
  1167. Isotropic atomic displacement parameter, or equivalent isotropic
  1168. atomic displacement parameter, B(equiv), in angstroms squared,
  1169. calculated from anisotropic displacement components.
  1170.  
  1171. B(equiv) = (1/3) sum~i~[sum~j~(B^ij^ a*~i~ a*~j~ a~i~ a~j~)]
  1172.  
  1173. a = the real-space cell lengths
  1174. a* = the reciprocal-space cell lengths
  1175. B^ij^ = 8 pi^2^ U^ij^
  1176.  
  1177. Ref: Fischer, R. X. & Tillmanns, E. (1988). Acta Cryst. C44,
  1178. 775-776.
  1179. */
  1180. Out_CIF_newfile(ciffile)
  1181. Out_String("\nloop_")
  1182. Out_String("\n\t_atom_site_label")
  1183. Out_String("\n\t_atom_site_type_symbol")
  1184. Out_String("\n\t_atom_site_site_symmetry_multiplicity")
  1185. Out_String("\n\t_atom_site_fract_x")
  1186. Out_String("\n\t_atom_site_fract_y")
  1187. Out_String("\n\t_atom_site_fract_z")
  1188. Out_String("\n\t_atom_site_occupancy")
  1189. Out_String("\n\t_atom_site_B_iso_or_equiv")
  1190. atom_out ciffile append
  1191. load out_record out_fmt out_eqn {
  1192. "\n%s" = Get_From_String(Get(current_atom), site);
  1193. "\t%s" = Get_From_String(Get(current_atom), atom);
  1194. "\t%3.0f" = Get_From_String(Get(current_atom), num_posns);
  1195. "\t%V" = Get_From_String(Get(current_atom), x);
  1196. "\t%V" = Get_From_String(Get(current_atom), y);
  1197. "\t%V" = Get_From_String(Get(current_atom), z);
  1198. "\t%V" = Get_From_String(Get(current_atom), occ);
  1199. "\t%V" = Get_From_String(Get(current_atom), beq);
  1200. }
  1201. }
  1202.  
  1203. macro Out_CIF_hkls(ciffile) {
  1204. /*
  1205. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_index_.html
  1206. _refln_index_h
  1207. _refln_index_k
  1208. _refln_index_l
  1209. Miller indices of the reflection. The values of the Miller
  1210. indices in the REFLN category must correspond to the cell
  1211. defined by the cell lengths and cell angles in the CELL category.
  1212.  
  1213. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_d_spacing.html
  1214. _refln_d_spacing
  1215. The d spacing in angstroms for this reflection. This is related
  1216. to the (sin theta)/lambda value by the expression
  1217. _refln_d_spacing = 2/(_refln_sint/lambda)
  1218.  
  1219. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Irefln_F_squared_.html
  1220. _refln_F_squared_calc
  1221. _refln_F_squared_meas
  1222. Calculated, measured and estimated standard uncertainty (derived
  1223. from measurement) of the squared structure factors (in electrons
  1224. squared for X-ray diffraction).
  1225. */
  1226. Out_CIF_newfile(ciffile)
  1227. Out_String("\nloop_")
  1228. Out_String("\n\t_refln_index_h")
  1229. Out_String("\n\t_refln_index_k")
  1230. Out_String("\n\t_refln_index_l")
  1231. Out_String("\n\t_refln_d_spacing")
  1232. Out_String("\n\t_refln_F_squared_calc")
  1233. Out_String("\n\t_refln_F_squared_meas")
  1234. phase_out ciffile append
  1235. load out_record out_fmt out_eqn {
  1236. "\n%4.0f" = H;
  1237. "\t%4.0f" = K;
  1238. "\t%4.0f" = L;
  1239. "\t%11.6f" = D_spacing;
  1240. "\t%12.6f" = I_no_scale_pks;
  1241. "\t%12.6f" = Iobs_no_scale_pks;
  1242. }
  1243. }
  1244.  
  1245. macro Out_CIF_adps(ciffile) {
  1246. /*
  1247. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_aniso_label.html
  1248. _atom_site_aniso_label
  1249. Anisotropic atomic displacement parameters are usually looped in
  1250. a separate list. If this is the case, this code must match the
  1251. _atom_site_label of the associated atom in the atom coordinate
  1252. list and conform with the same rules described in
  1253. _atom_site_label.
  1254.  
  1255. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_aniso_U_.html
  1256. _atom_site_aniso_U_11
  1257. _atom_site_aniso_U_22
  1258. _atom_site_aniso_U_33
  1259. _atom_site_aniso_U_12
  1260. _atom_site_aniso_U_13
  1261. _atom_site_aniso_U_23
  1262. These are the standard anisotropic atomic displacement
  1263. components in angstroms squared which appear in the
  1264. structure-factor term
  1265.  
  1266. T = exp{-2pi^2^ sum~i~ [sum~j~ (U^ij^ h~i~ h~j~ a*~i~ a*~j~) ] }
  1267.  
  1268. h = the Miller indices
  1269. a* = the reciprocal-space cell lengths
  1270.  
  1271. The unique elements of the real symmetric matrix are
  1272. entered by row.
  1273. */
  1274. Out_CIF_newfile(ciffile)
  1275. Out_String("\nloop_")
  1276. Out_String("\n\t_atom_site_aniso_label")
  1277. Out_String("\n\t_atom_site_aniso_U_11")
  1278. Out_String("\n\t_atom_site_aniso_U_22")
  1279. Out_String("\n\t_atom_site_aniso_U_33")
  1280. Out_String("\n\t_atom_site_aniso_U_12")
  1281. Out_String("\n\t_atom_site_aniso_U_13")
  1282. Out_String("\n\t_atom_site_aniso_U_23")
  1283. atom_out ciffile append
  1284. load out_record out_fmt out_eqn {
  1285. "\n%s" = Get_From_String(Get(current_atom), site);
  1286. "\t%V" = Get_From_String(Get(current_atom), u11);
  1287. "\t%V" = Get_From_String(Get(current_atom), u22);
  1288. "\t%V" = Get_From_String(Get(current_atom), u33);
  1289. "\t%V" = Get_From_String(Get(current_atom), u12);
  1290. "\t%V" = Get_From_String(Get(current_atom), u13);
  1291. "\t%V" = Get_From_String(Get(current_atom), u23);
  1292. }
  1293. }
  1294.  
  1295. macro Out_CIF_bond_angles(ciffile) {
  1296. /*
  1297. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Igeom_bond_atom_site_label_.html
  1298. _geom_bond_atom_site_label_1
  1299. _geom_bond_atom_site_label_2
  1300. The labels of two atom sites that form a bond. These must match
  1301. labels specified as _atom_site_label in the atom list.
  1302.  
  1303. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Igeom_bond_distance.html
  1304. _geom_bond_distance
  1305. The intramolecular bond distance in angstroms.
  1306.  
  1307. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Igeom_bond_site_symmetry_.html
  1308. _geom_bond_site_symmetry_1
  1309. _geom_bond_site_symmetry_2
  1310. The symmetry code of each atom site as the symmetry-equivalent
  1311. position number 'n' and the cell translation number 'klm'.
  1312. These numbers are combined to form the code 'n klm' or n_klm.
  1313. The character string n_klm is composed as follows:
  1314.  
  1315. n refers to the symmetry operation that is applied to the
  1316. coordinates stored in _atom_site_fract_x, _atom_site_fract_y
  1317. and _atom_site_fract_z. It must match a number given in
  1318. _space_group_symop_id.
  1319.  
  1320. k, l and m refer to the translations that are subsequently
  1321. applied to the symmetry-transformed coordinates to generate
  1322. the atom used in calculating the bond. These translations
  1323. (x,y,z) are related to (k,l,m) by the relations
  1324. k = 5 + x
  1325. l = 5 + y
  1326. m = 5 + z
  1327. By adding 5 to the translations, the use of negative numbers
  1328. is avoided.
  1329.  
  1330. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Igeom_angle_atom_site_label_.html
  1331. _geom_angle_atom_site_label_1
  1332. _geom_angle_atom_site_label_2
  1333. _geom_angle_atom_site_label_3
  1334. The labels of the three atom sites which define the angle
  1335. given by _geom_angle. These must match labels specified as
  1336. _atom_site_label in the atom list. Label 2 identifies the site at
  1337. the apex of the angle.
  1338.  
  1339. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Igeom_angle.html
  1340. _geom_angle
  1341. Angle in degrees defined by the three sites
  1342. _geom_angle_atom_site_label_1, *_2 and *_3. The site at *_2
  1343. is at the apex of the angle.
  1344.  
  1345. https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Igeom_angle_site_symmetry_.html
  1346. _geom_angle_site_symmetry_1
  1347. _geom_angle_site_symmetry_2
  1348. _geom_angle_site_symmetry_3
  1349. The symmetry code of each atom site as the symmetry-equivalent
  1350. position number 'n' and the cell translation number 'klm'.
  1351. These numbers are combined to form the code 'n klm' or n_klm.
  1352. The character string n_klm is composed as follows:
  1353.  
  1354. n refers to the symmetry operation that is applied to the
  1355. coordinates stored in _atom_site_fract_x, _atom_site_fract_y
  1356. and _atom_site_fract_z. It must match a number given in
  1357. _space_group_symop_id.
  1358.  
  1359. k, l and m refer to the translations that are subsequently
  1360. applied to the symmetry-transformed coordinates to generate
  1361. the atom used in calculating the angle. These translations
  1362. (x,y,z) are related to (k,l,m) by the relations
  1363. k = 5 + x
  1364. l = 5 + y
  1365. m = 5 + z
  1366. By adding 5 to the translations, the use of negative numbers
  1367. is avoided.
  1368. */
  1369. Out_CIF_newfile(ciffile)
  1370. consider_lattice_parameters 'this propagates errors from lattice parameters to the bonds and angles'
  1371. Out(Get(cif_bonds_angles), "%s")
  1372. }
  1373.  
  1374. macro Out_magCIF_space_group_with_id {
  1375. /*
  1376. https://www.iucr.org/__data/iucr/cifdic_html/3/MAGNETIC_CIF/Ispace_group_magn.number_BNS.html
  1377. _space_group_magn.number_BNS
  1378. See _space_group_magn.number_OG for a description of magnetic
  1379. space groups (MSGs). The Belov-Neronova-Smirnova (BNS) number for
  1380. an MSG is composed of two positive integers separated by a
  1381. period. The first integer lies in the range [1-230] and indicates
  1382. the non-magnetic space group F for MSGs of types 1-3 or the
  1383. non-magnetic space group of the subgroup D for MSGs of type 4. The
  1384. second integer is sequential over all MSGs associated with the
  1385. same crystal family.
  1386. There are 1651 distinct equivalence classes of MSGs, each of
  1387. which has a unique BNS number. These equivalence classes are most
  1388. accurately referred to as magnetic space-group "types",
  1389. following the usage in the International Tables for Crystallography.
  1390. But the word "type" is also commonly used to
  1391. indicate the four-fold classification of MSGs presented above.
  1392. To avoid confusion, the word "type" is only used in the latter
  1393. sense here.
  1394.  
  1395. Analogous tags: symCIF:_space_group.number_IT
  1396.  
  1397. Ref: 'Magnetic Group Tables' by D.B. Litvin at
  1398. http://www.iucr.org/publ/978-0-9553602-2-0. ISO-MAG tables of H.T.
  1399. Stokes and B.J. Campbell at http://iso.byu.edu.
  1400.  
  1401. https://www.iucr.org/__data/iucr/cifdic_html/3/MAGNETIC_CIF/Ispace_group_symop_magn_operation.id.html
  1402. _space_group_symop_magn_operation.id
  1403. An arbitrary identifier that uniquely labels each symmetry
  1404. operation in a looped list of magnetic space-group symmetry
  1405. operations. Most commonly, a sequence of positive integers is
  1406. used for this identification.
  1407. The _space_group_symop_magn.id alias provides backwards
  1408. compatibility with the established magCIF prototype.
  1409.  
  1410. https://www.iucr.org/__data/iucr/cifdic_html/3/MAGNETIC_CIF/Ispace_group_symop_magn_operation.xyz.html
  1411. _space_group_symop_magn_operation.xyz
  1412. A parsable string giving one of the symmetry operations of the
  1413. magnetic space group in algebraic form. The analogy between
  1414. parsable labels for magnetic and non-magnetic symmetry operations
  1415. is perfect except for the fact that a magnetic symop label ends
  1416. with an additional piece of information ("-1" or "+1") indicating
  1417. that the operation is or is not time-reversed, respectively.
  1418. This tag is intended for use with the BNS-supercell description
  1419. of a magnetic structure.
  1420.  
  1421. Analogous tags: symCIF:_space_group_symop.operation_xyz
  1422.  
  1423. Ref: 'Magnetic Group Tables' by D.B. Litvin at
  1424. http://www.iucr.org/publ/978-0-9553602-2-0. ISO-MAG tables of H.T.
  1425. Stokes and B.J. Campbell at http://iso.byu.edu.
  1426.  
  1427. _space_group_symop.magn_operation.mxmymz
  1428. I cannot find a definition in the magCIF for this column.
  1429.  
  1430. _space_group_symop.magn_operation.timereversal
  1431. Topas does not include the time reversal in the xyz output.
  1432. It goes in its own column.
  1433.  
  1434. */
  1435. Out(Get(sp_grp_char ), "\n_space_group_magn.number_BNS\t%s")
  1436. Out_String("\nloop_")
  1437. Out_String("\n\t_space_group_symop_magn_operation.id")
  1438. Out_String("\n\t_space_group_symop_magn_operation.xyz")
  1439. Out_String("\n\t_space_group_symop_magn_operation.mxmymz")
  1440. Out_String("\n\t_space_group_symop_magn_operation.timereversal")
  1441. Out(Get(mag_sp_xyzs_txt_with_id), "%s")
  1442. }
  1443.  
  1444. macro Out_mag_CIF_atom_site_moment {
  1445. /*
  1446. https://www.iucr.org/__data/iucr/cifdic_html/3/MAGNETIC_CIF/Iatom_site_moment.label.html
  1447. _atom_site_moment.label
  1448.  
  1449. https://www.iucr.org/__data/iucr/cifdic_html/3/MAGNETIC_CIF/Iatom_site_moment.crystalaxis_x.html
  1450. _atom_site_moment.crystalaxis_x
  1451. The component of the atom-site magnetic-moment vector parallel to the first
  1452. unit-cell axis. See _atom_site_moment.crystalaxis.
  1453.  
  1454. https://www.iucr.org/__data/iucr/cifdic_html/3/MAGNETIC_CIF/Iatom_site_moment.crystalaxis_y.html
  1455. _atom_site_moment.crystalaxis_y
  1456. The component of the atom-site magnetic-moment vector parallel to the second
  1457. unit-cell axis. See _atom_site_moment.crystalaxis.
  1458.  
  1459. https://www.iucr.org/__data/iucr/cifdic_html/3/MAGNETIC_CIF/Iatom_site_moment.crystalaxis_z.html
  1460. _atom_site_moment.crystalaxis_z
  1461. The component of the atom-site magnetic-moment vector parallel to the third
  1462. unit-cell axis. See _atom_site_moment.crystalaxis.
  1463. */
  1464. Out_CIF_newfile(ciffile)
  1465. Out_String("\nloop_")
  1466. Out_String("\n\t_atom_site_moment.label")
  1467. Out_String("\n\t_atom_site_moment.crystalaxis_x")
  1468. Out_String("\n\t_atom_site_moment.crystalaxis_y")
  1469. Out_String("\n\t_atom_site_moment.crystalaxis_z")
  1470. mag_atom_out ciffile append
  1471. load out_record out_fmt out_eqn {
  1472. "\n%s" = Get_From_String(Get(current_atom), site);
  1473. "\t%11.5f" = Get(a) Get_From_String(Get(current_atom), mlx);
  1474. "\t%11.5f" = Get(b) Get_From_String(Get(current_atom), mly);
  1475. "\t%11.5f" = Get(c) Get_From_String(Get(current_atom), mlz);
  1476. }
  1477. }
  1478.  
  1479. '##############################################################%####### '
  1480. ' These are the consoldiated macros to report structures and patterns '
  1481. '###################################################################### '
  1482.  
  1483.  
  1484. macro Out_pdCIF_xdd_setup {
  1485. /*
  1486. This macro sets up a workaround in how pk_xo behaves differently between v5-6 and v7
  1487. It also defines an ID prm, so you do not need to if there is only one xdd to worry about.
  1488. */
  1489. if Or(Obj_There(pk_xo_prm),Obj_There(pk_xo)) { local !pk_xo_exists 0 }
  1490. if Prm_There(CIF_ID) {
  1491. 'do nothing'
  1492. } else {
  1493. if Prm_There(CIF_MULTI_DIFFRACTOGRAM_ID) {
  1494. if Obj_There(num_runs) {
  1495. local CIF_ID = Run_Number;
  1496. } else {
  1497. local CIF_ID 1
  1498. }
  1499. } else { 'not a multi-pattern inp file'
  1500. if Obj_There(range) {
  1501. if Obj_There(num_runs) {
  1502. local CIF_ID = 10000 Get(range) + Run_Number;
  1503. } else {
  1504. local CIF_ID = Get(range);
  1505. }
  1506. } else if Obj_There(num_runs) {
  1507. local CIF_ID = Run_Number;
  1508. } else {
  1509. local CIF_ID 1
  1510. }
  1511. }
  1512. }
  1513. }
  1514.  
  1515. macro Out_pdCIF_STR(ciffile, phase_id, id) {
  1516. Out_pdCIF_STR(ciffile, phase_id, id,,)
  1517. }
  1518. macro Out_pdCIF_STR(ciffile, phase_id, id, n, m) {
  1519. /*
  1520. This macro constructs a crystal structure in CIF format that is likely
  1521. to pass checkCIF with minimal issues. Probably.
  1522.  
  1523. The construction of the block_id is simply the concatenation of the
  1524. phase_name and an identifier, most usually taken as the number of the xdd,
  1525. either defined through the use of "Run_Number" if doing a sequential refinement
  1526. using #list, or by setting a local variable in each xdd - local !id = 1; (and
  1527. copying it and incrementing it in each xdd)
  1528.  
  1529. The diffractogram_id of each diffraction pattern is simply the string "pattern_"
  1530. with the id appended. This is also set to be the block id of the diffraction
  1531. pattern in the diffraction pattern macro.
  1532.  
  1533. The implementation of the block_id and diffractogram_id in is this macro is
  1534. extremely simplistic, and designed to be easily automated. If you change how
  1535. the _pd_block_id or _pd_diffractogram_id is implemented, make
  1536. sure to change it in all the other places - see _pd_phase_block_id also.
  1537.  
  1538. This macro can be placed into every str that you have, or better, placed at the end
  1539. of the input file in a `for strs {}` construct.
  1540.  
  1541.  
  1542. ciffile: the name of the file you want to write to. The data is appended.
  1543. phase_id: a number uniquely identifying a str inside an xdd
  1544. id: a number uniquely identifying an xdd
  1545.  
  1546. If you want to report molecular weight for a str, you must define a
  1547. local parameter defining the number of formula units. ie:
  1548. local !CIF_Z = 6;
  1549. You must name it "CIF_Z".
  1550. */
  1551. Out_CIF_newfile(ciffile)
  1552. Out_String("\n")
  1553. Out_CIF_section_break("Begin powder crystal structure")
  1554. Out_CIF_datablock_dataname Out_unique_phase_id(id)
  1555. Out_pdCIF_blockid_dataname Out_unique_phase_id(id)
  1556. if Prm_There(CIF_MULTI_DIFFRACTOGRAM_ID) {
  1557. Out_String("\n# The diffractogram block id loop is at the end of the datablock.")
  1558. } else {
  1559. Out_pdCIF_diffractogramid_dataname Out_unique_diffractogram_id(id)
  1560. }
  1561. if Prm_There(CIF_DIFFRACTOMETER_NAME) { Out_CIF_diffrn_measurement_device_type(CIF_DIFFRACTOMETER_NAME) }
  1562. Out_pdCIF_phase_name
  1563. Out_CIF_unit_cell_prms
  1564. if Prm_There(CIF_Z) { Out_CIF_Z_molecular_weight(CIF_Z) }
  1565. if Prm_There(CIF_SUM_FORMULA) { Out_CIF_chemical_formula(CIF_SUM_FORMULA) }
  1566. if Prm_There(CIF_TEMP) { Out_CIF_cell_temperature(CIF_TEMP) }
  1567. if Prm_There(CIF_PRES) { Out_CIF_cell_pressure(CIF_PRES) }
  1568. Out_CIF_density
  1569. TOF_ED_CW(,, Out_CIF_absorption Out_CIF_wavelength Out_CIF_minmax_theta)
  1570. if Prm_There(CIF_CRYSTAL_SYSTEM) { Out_CIF_space_group_crystal_system(CIF_CRYSTAL_SYSTEM) }
  1571. if Prm_There(CIF_PHASE_TEXT) { Out_CIF_free_text(CIF_PHASE_TEXT) }
  1572. if Obj_There(mag_sg) {
  1573. Out_magCIF_space_group_with_id
  1574. } else {
  1575. Out_CIF_space_group_with_id
  1576. }
  1577. Out_CIF_atom_coords(ciffile)
  1578. if Obj_There(adps) { Out_CIF_adps(ciffile) }
  1579. if Obj_There(mag_sg) { Out_mag_CIF_atom_site_moment }
  1580. Out_CIF_bond_angles(ciffile)
  1581. Out_CIF_newfile(ciffile)
  1582. if Prm_There(CIF_MULTI_DIFFRACTOGRAM_ID) {
  1583. 'this is down here as there are TOPAS internal pointer details that do not allow it up there ^'
  1584. Out_String("\nloop_")
  1585. Out_pdCIF_diffractogramid_dataname
  1586. for xdds n_to_m(n,m) {
  1587. Out_String("\n\t")
  1588. Out_unique_diffractogram_id(id)
  1589. }
  1590. 'Cannot have any references to str things after this for xdds loop.'
  1591. }
  1592. Out_CIF_newfile(ciffile)
  1593. Out_CIF_section_break("End powder crystal structure")
  1594. Out_String("\n")
  1595. }
  1596.  
  1597. macro Out_pdCIF_diffraction_data(ciffile, data_type, bkg_eqn, phase_id, id) {
  1598. /*
  1599. This macro constructs a powder diffraction pattern in CIF format.
  1600.  
  1601. The construction of the block_id is simply the concatenation of the
  1602. string "pattern" and an identifier, most usually taken as the number of the xdd,
  1603. either defined through the use of "Run_Number" if doing a sequential refinement
  1604. using #list, or by setting a local variable in each xdd - local !id = 1; (and
  1605. copying it and incrementing it in each xdd)
  1606.  
  1607. The implementation of the block_id in this macro is extremely simplistic, and
  1608. designed to be easily automated. If you change how the _pd_block_id or
  1609. _pd_diffractogram_id is implemented, make sure to change it in all the other
  1610. places - see _pd_phase_block_id also.
  1611.  
  1612. This macro can be placed into every xdd that you have, or if you have more, placed
  1613. at the end of the input file in a `for xdds {}` construct.
  1614.  
  1615. ciffile: the name of the file you want to write to. The data is appended.
  1616. data_type: "meas" - data as-measured; "proc" - data has been processed before analysis
  1617. bkg_eqn: an equation with the bkg you want to record
  1618. phase_id: a number uniquely identifiying a str in an xdd
  1619. is: a number uniquely identifying an xdd, or group of xdds in the case of a multi-pattern refinement
  1620. */
  1621. Out_CIF_newfile(ciffile)
  1622. Out_String("\n")
  1623. Out_CIF_section_break("Begin powder diffraction data")
  1624. Out_CIF_datablock_dataname Out_unique_diffractogram_id(id)
  1625. Out_pdCIF_blockid_dataname Out_unique_diffractogram_id(id)
  1626. if Prm_There(CIF_DATETIME) { Out_pdCIF_datetime_initiated(CIF_DATETIME) }
  1627. Out_String("\n_pd_calc_method\tRietveld")
  1628. if Obj_There(neutron) {
  1629. Out_String("\n_diffrn_radiation_probe\tneutron")
  1630. } else {
  1631. Out_String("\n_diffrn_radiation_probe\tx-ray")
  1632. }
  1633. if Prm_There(CIF_DIFFRACTOMETER_NAME) { Out_pdCIF_instr_special_details(CIF_DIFFRACTOMETER_NAME) }
  1634. TOF_ED_CW(Out_pdCIF_scan_method("tof"),
  1635. Out_pdCIF_scan_method("disp"),
  1636. if Prm_There(CIF_SCAN_METHOD) { Out_pdCIF_scan_method(CIF_SCAN_METHOD) }
  1637. if Obj_There(lam) { Out_CIF_wavelength } )
  1638. if Prm_There(CIF_TEMP) { Out_CIF_temperature(CIF_TEMP) }
  1639. if Prm_There(CIF_PRES) { Out_CIF_pressure(CIF_PRES) }
  1640. Out_CIF_Rfactors
  1641. if Prm_There(CIF_DIFFRACTOGRAM_TEXT) { Out_CIF_free_text(CIF_DIFFRACTOGRAM_TEXT) }
  1642. if Obj_There(str) {
  1643. Out_pdCIF_phase_block_id(phase_id, id)
  1644. Out_pdCIF_hkls_header(ciffile)
  1645. Out_pdCIF_hkls(ciffile, phase_id)
  1646. }
  1647. TOF_ED_CW(Out_pdCIF_time_of_flight_data(ciffile, data_type, bkg_eqn),
  1648. Out_pdCIF_energy_dispersive_data(ciffile, data_type, bkg_eqn),
  1649. Out_pdCIF_angle_dispersive_data(ciffile, data_type, bkg_eqn))
  1650. Out_CIF_newfile(ciffile)
  1651. Out_CIF_section_break("End powder diffraction data")
  1652. Out_String("\n")
  1653. }
  1654.  
  1655. macro Out_CIF_magic_number(ciffile) {
  1656. 'write the CIF version number to file.'
  1657. out ciffile append
  1658. Out_String("#\#CIF_1.1\n")
  1659. }
  1660. '##############################################################%##################################### '
  1661. '#################################################################################################### '
  1662. '###################################################################################################### '
  1663. '###################################################################################################### '
  1664. '#################################################################################################### '
  1665. '#################################################################################################### '
  1666.  
  1667. /* The macros to use at the end of your input file (literally)
  1668. to report structures and patterns is just after this comment!
  1669.  
  1670. There are some helper macros that have fewer arguments, and make some
  1671. choices about what to write in the CIF file for you.
  1672.  
  1673. The use of these macros rely on you using some predefined parameters
  1674. for specific items. You can use whatever name you want in your own
  1675. calculations, and you only need to use them if you want to report on them,
  1676. but they need to be defined somewhere with the following names:
  1677.  
  1678. -Must be defined (eg local CIF_PHASE_ID 2 )
  1679. CIF_ID - (per xdd, or group of xdds) unique identifier to append to block ids to ensure everything is unique
  1680. CIF_PHASE_ID - (per str) unique identifier to append to block ids of strs to ensure everything is unique
  1681. t0, t1, t2 - (per xdd - only for tof) TOF calibration constants
  1682. CIF_TH2_FIXED - (per xdd - only for edxrd) Detector angle in energy-dispersive XRD
  1683.  
  1684. -Should be defined
  1685. CIF_SCAN_METHOD - (per xdd) "step" - step scan; "cont" continuous scan; "fixed" stationary detector.
  1686. This is only relevant for CW data.
  1687.  
  1688. -Can be defined
  1689. CIF_DATETIME xdd Date/time when data collection was initiated
  1690. CIF_TEMP - (per xdd) Temperature (K) at which data were acquired.
  1691. CIF_PRES - (per xdd) Pressure (kPa) at which data were acquired.
  1692. CIF_Z - (per str) formula units per unit cell
  1693. CIF_SUM_FORMULA - (per str) what is the chemical formula of the unit cell?
  1694. CIF_CRYSTAL_SYSTEM - (per str) the crystal system of the space group
  1695. CIF_DIFFRACTOMETER_NAME - (per xdd) short description of the diffractometer
  1696. (If you use these next two, you are on your own wrt maintaining uniqueness
  1697. CIF_DIFFRACTOGRAM_BLOCK_ID xdd Fully specified block ID for a diffraction pattern
  1698. CIF_PHASE_BLOCK_ID str Fully specified block ID for a crystal structure
  1699. CIF_DIFFRACTOGRAM_TEXT xdd Free-text entry that goes in the data block containing the diffraction data
  1700. CIF_PHASE_TEXT str Free-text entry that goes in the data block containing the structure
  1701.  
  1702.  
  1703. ciffile: the name of the file you want to write to. The data is appended.
  1704. data_type: "meas" - data as-measured; or "proc" - data has been processed before analysis
  1705. bkg_eqn: an equation defining your background function so it can be ouput in the CIF
  1706. n,m: numbers representing the xdds over which the output should be run.
  1707. */
  1708. '######################################################################'
  1709.  
  1710. macro Out_pdCIF_per_xdd(ciffile) { Out_pdCIF_per_xdd(ciffile, "proc", =Get(bkg);) }
  1711. macro Out_pdCIF_per_xdd(ciffile, data_type) { Out_pdCIF_per_xdd(ciffile, data_type, =Get(bkg);) }
  1712. macro Out_pdCIF_per_xdd(ciffile, data_type, bkq_eqn) {
  1713. /*
  1714. If you wish to change the output on a per-xdd basis, use this macro in each xdd.
  1715. Otherwise, use Out_pdCIF()
  1716. */
  1717. Out_pdCIF_xdd_setup
  1718. if Obj_There(str) { for strs { Out_pdCIF_STR(ciffile, CIF_PHASE_ID, CIF_ID) } }
  1719. Out_pdCIF_diffraction_data(ciffile, data_type, bkq_eqn, CIF_PHASE_ID, CIF_ID)
  1720. }
  1721.  
  1722.  
  1723. macro Out_pdCIF(ciffile) { Out_pdCIF(ciffile, "proc", =Get(bkg);) }
  1724. macro Out_pdCIF(ciffile, data_type) { Out_pdCIF(ciffile, data_type, =Get(bkg);) }
  1725. macro Out_pdCIF(ciffile, data_type, bkq_eqn) { Out_pdCIF(ciffile, data_type, bkq_eqn, , ) }
  1726. macro Out_pdCIF(ciffile, data_type, bkq_eqn, n, m) {
  1727. /*
  1728. This is the macro to use if the structures in each xdd are independent of each other
  1729. ie, they are not being co-refined on multiple datasets
  1730.  
  1731. Some examples on how to use the Out_pdCIF macro:
  1732.  
  1733. -----------------------------------------------
  1734. # 1: single pattern, many strs
  1735. xdd
  1736. ...
  1737. str
  1738. local CIF_PHASE_ID 1
  1739. local !CIF_Z = 2;
  1740. ...
  1741. str
  1742. local CIF_PHASE_ID 2
  1743. ...
  1744. str
  1745. local CIF_PHASE_ID 3
  1746. ...
  1747. macro CIF_OUTPUT_FILE { "filename.cif" }
  1748. Out_pdCIF(CIF_OUTPUT_FILE)
  1749. -----------------------------------------------
  1750. -----------------------------------------------
  1751. # 2: many patterns, many strs
  1752. xdd
  1753. local CIF_ID 1
  1754. local !CIF_SCAN_METHOD = "fixed";
  1755. local CIF_PRES 100
  1756. ...
  1757. str
  1758. local CIF_PHASE_ID 1
  1759. ...
  1760. xdd
  1761. local CIF_ID 2
  1762. local !CIF_SCAN_METHOD = "cont";
  1763. local CIF_PRES 400
  1764. ...
  1765. str
  1766. local CIF_PHASE_ID 1
  1767. ...
  1768. str
  1769. local CIF_PHASE_ID 2
  1770. local !CIF_Z 6
  1771. ...
  1772. str
  1773. local CIF_PHASE_ID 3
  1774. ...
  1775. ...
  1776. Out_pdCIF("filename.cif", meas)
  1777.  
  1778. -----------------------------------------------
  1779. -----------------------------------------------
  1780. # 3: sequential refinement, multiple strs
  1781.  
  1782. macro CIF_OUTPUT_FILE { "filename.cif" }
  1783. num_runs 30
  1784. #list File_Name Temperature {
  1785. file_01.xye 30
  1786. file_02.xye 45
  1787. ...
  1788. }
  1789. prm CIF_ID = Run_Number;
  1790. prm CIF_TEMP = Temperature(Run_Number);
  1791. prm CIF_SCAN_METHOD = "fixed";
  1792. xdd
  1793. ...
  1794. str
  1795. local CIF_PHASE_ID 1
  1796. local !CIF_Z = 6;
  1797. ...
  1798. str
  1799. local CIF_PHASE_ID 2
  1800. local !CIF_Z = 8;
  1801. ...
  1802. str
  1803. local CIF_PHASE_ID 3
  1804. ...
  1805. Out_pdCIF(CIF_OUTPUT_FILE, meas)
  1806. -----------------------------------------------
  1807. */
  1808. for xdds n_to_m(n,m) {
  1809. Out_pdCIF_per_xdd(ciffile, data_type, bkq_eqn)
  1810. }
  1811. }
  1812.  
  1813. macro Out_pdCIF_multi(ciffile) { Out_pdCIF_multi(ciffile, "proc", =Get(bkg);) }
  1814. macro Out_pdCIF_multi(ciffile, data_type) { Out_pdCIF_multi(ciffile, data_type, =Get(bkg);) }
  1815. macro Out_pdCIF_multi(ciffile, data_type, bkg_eqn) { Out_pdCIF_multi(ciffile, data_type, bkg_eqn, 1, ) }
  1816. macro Out_pdCIF_multi(ciffile, data_type, bkg_eqn, n, m) {
  1817. /*
  1818. This is the macro to use if the structures in each xdd are dependent of each other
  1819. ie, all structures are being co-refined on all xdds and all structures are present
  1820. in all xdds
  1821.  
  1822. eg multi-bank TOF data.
  1823.  
  1824. Some examples on how to use the Out_pdCIF_multi macro:
  1825.  
  1826. -----------------------------------------------
  1827. # 1: multiple patterns, multiple strs
  1828. prm CIF_ID 1
  1829. prm CIF_TEMP 5
  1830. xdd 'eg bank 1 of a tof dataset'
  1831. ...
  1832. str
  1833. local CIF_PHASE_ID 1
  1834. ...
  1835. str
  1836. local CIF_PHASE_ID 2
  1837. ...
  1838. str
  1839. local CIF_PHASE_ID 3
  1840. ...
  1841. xdd 'eg bank 2 of a tof dataset'
  1842. ...
  1843. str
  1844. local CIF_PHASE_ID 1
  1845. ...
  1846. str
  1847. local CIF_PHASE_ID 2
  1848. local !CIF_Z 6
  1849. ...
  1850. str
  1851. local CIF_PHASE_ID 3
  1852. ...
  1853. ...
  1854. Out_pdCIF_multi("filename.cif", proc)
  1855.  
  1856. -----------------------------------------------
  1857. -----------------------------------------------
  1858. # 2: sequential refinement, multiple strs,
  1859.  
  1860. macro CIF_OUTPUT_FILE { "filename.cif" }
  1861. num_runs 30
  1862. #list File_Name_b1 File_Name_b2 File_Name_b3 Temperature {
  1863. file_b1_01.xye file_b2_01.xye file_b3_01.xye 30
  1864. file_b1_02.xye file_b2_02.xye file_b3_02.xye 35
  1865. ...
  1866. }
  1867. prm CIF_ID = Run_Number;
  1868. prm CIF_TEMP = Temperature(Run_Number);
  1869. xdd File_Name_b1(Run_Number)
  1870. ...
  1871. str
  1872. ...
  1873. str
  1874. ...
  1875. xdd File_Name_b2(Run_Number)
  1876. ...
  1877. str
  1878. ...
  1879. str
  1880. ...
  1881. xdd File_Name_b3(Run_Number)
  1882. ...
  1883. str
  1884. ...
  1885. str
  1886. ...
  1887. for xdds {
  1888. local CIF_SCAN_METHOD = "cont";
  1889. for strs 1 to 1 {
  1890. local CIF_PHASE_ID 1
  1891. local CIF_Z = 6;
  1892. }
  1893. for strs 2 to 2 {
  1894. local CIF_PHASE_ID 2
  1895. local CIF_Z = 8;
  1896. }
  1897. }
  1898. Out_pdCIF_multi(CIF_OUTPUT_FILE, meas)
  1899. -----------------------------------------------
  1900. */
  1901. for xdds n_to_m(n,m) {
  1902. Out_pdCIF_xdd_setup
  1903. local CIF_MULTI_DIFFRACTOGRAM_ID 1
  1904. }
  1905. Out_CIF_newfile(ciffile)
  1906. for xdds n to n { if Obj_There(str) { for strs { Out_pdCIF_STR(ciffile, CIF_PHASE_ID, CIF_ID, n, m) } } }
  1907. for xdds n_to_m(n,m) { Out_pdCIF_diffraction_data(ciffile, data_type, bkg_eqn, CIF_PHASE_ID, CIF_ID) }
  1908. }
  1909. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement