Skip to content

Commit 449176c

Browse files
committed
Demo the Bond Valence Sum calculator.
Example calculation for NaCl and optional customization of bond valence parameters.
1 parent f35a0e7 commit 449176c

File tree

4 files changed

+332
-3
lines changed

4 files changed

+332
-3
lines changed

cmi_scripts/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ problem you are interested in.
88
Contents
99
--------
1010

11+
* [calcbvsnacl](./calcbvsnacl) - Calculate bond valence sums for NaCl
12+
using standard and custom valence parameters.
13+
1114
* [calcpdfc60](./calcpdfc60) - Calculate and plot a PDF for C60 from a stru
1215
file. Uses the DebyePDFCalculator from DiffPy-CMI.
1316

1417
* [calcpdfcds](./calcpdfcds) - Calculate and plot a PDF for CdS wurtzite from
1518
a cif file. Uses the PDFCalculator module from DiffPy-CMI.
1619

17-
* [fitCdSeNP](./fitCdSeNP) - Fit the PDF of CdSe nanoparticles using a
20+
* [fitCdSeNP](./fitCdSeNP) - Fit the PDF of CdSe nanoparticles using a
1821
non-periodic structure model.
1922

2023
* [fitCdSeNP](./fitNiPDF) - Fit a Ni neutron PDF using a periodic Ni structure
@@ -33,9 +36,9 @@ Some of the above examples are written as IPython notebooks (extension
3336
similar to Mathematica. To start notebook mode in IPython, run the command
3437

3538
ipython notebook
36-
39+
3740
You can then load the .ipynb file directly into your workspace. Alternatively,
38-
you can run
41+
you can run
3942

4043
ipython notebook name_of_notebook.ipynb
4144

cmi_scripts/calcbvsnacl/NaCl.cif

+267
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
#------------------------------------------------------------------------------
2+
#$Date: 2010-01-30 13:59:17 +0000 (Sat, 30 Jan 2010) $
3+
#$Revision: 966 $
4+
#$URL: svn://cod.ibt.lt/cod/cif/1/1000041.cif $
5+
#------------------------------------------------------------------------------
6+
#
7+
# This file is available in the Crystallography Open Database (COD),
8+
# http://www.crystallography.net/
9+
#
10+
# All data on this site have been placed in the public domain by the
11+
# contributors.
12+
#
13+
data_1000041
14+
15+
_chemical_name_systematic 'Sodium chloride'
16+
_chemical_formula_structural 'Na Cl'
17+
_chemical_formula_sum 'Cl Na'
18+
19+
_publ_section_title
20+
;
21+
Accuracy of an automatic diffractometer. measurement of the sodium
22+
chloride structure factors
23+
;
24+
loop_
25+
_publ_author_name
26+
'Abrahams, S C'
27+
'Bernstein, J L'
28+
_journal_name_full 'Acta Crystallographica (1,1948-23,1967)'
29+
_journal_coden_ASTM ACCRA9
30+
_journal_volume 18
31+
_journal_year 1965
32+
_journal_page_first 926
33+
_journal_page_last 932
34+
35+
_cell_length_a 5.62
36+
_cell_length_b 5.62
37+
_cell_length_c 5.62
38+
_cell_angle_alpha 90
39+
_cell_angle_beta 90
40+
_cell_angle_gamma 90
41+
_cell_volume 177.5
42+
_cell_formula_units_Z 4
43+
44+
_symmetry_space_group_name_H-M 'F m -3 m'
45+
_symmetry_Int_Tables_number 225
46+
_symmetry_cell_setting cubic
47+
48+
loop_
49+
_symmetry_equiv_pos_as_xyz
50+
'x,y,z'
51+
'y,z,x'
52+
'z,x,y'
53+
'x,z,y'
54+
'y,x,z'
55+
'z,y,x'
56+
'x,-y,-z'
57+
'y,-z,-x'
58+
'z,-x,-y'
59+
'x,-z,-y'
60+
'y,-x,-z'
61+
'z,-y,-x'
62+
'-x,y,-z'
63+
'-y,z,-x'
64+
'-z,x,-y'
65+
'-x,z,-y'
66+
'-y,x,-z'
67+
'-z,y,-x'
68+
'-x,-y,z'
69+
'-y,-z,x'
70+
'-z,-x,y'
71+
'-x,-z,y'
72+
'-y,-x,z'
73+
'-z,-y,x'
74+
'-x,-y,-z'
75+
'-y,-z,-x'
76+
'-z,-x,-y'
77+
'-x,-z,-y'
78+
'-y,-x,-z'
79+
'-z,-y,-x'
80+
'-x,y,z'
81+
'-y,z,x'
82+
'-z,x,y'
83+
'-x,z,y'
84+
'-y,x,z'
85+
'-z,y,x'
86+
'x,-y,z'
87+
'y,-z,x'
88+
'z,-x,y'
89+
'x,-z,y'
90+
'y,-x,z'
91+
'z,-y,x'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
147+
'1/2-y,x,1/2-z'
148+
'1/2-y,1/2+x,-z'
149+
'-z,1/2+y,1/2-x'
150+
'1/2-z,y,1/2-x'
151+
'1/2-z,1/2+y,-x'
152+
'-x,1/2-y,1/2+z'
153+
'1/2-x,-y,1/2+z'
154+
'1/2-x,1/2-y,z'
155+
'-y,1/2-z,1/2+x'
156+
'1/2-y,-z,1/2+x'
157+
'1/2-y,1/2-z,x'
158+
'-z,1/2-x,1/2+y'
159+
'1/2-z,-x,1/2+y'
160+
'1/2-z,1/2-x,y'
161+
'-x,1/2-z,1/2+y'
162+
'1/2-x,-z,1/2+y'
163+
'1/2-x,1/2-z,y'
164+
'-y,1/2-x,1/2+z'
165+
'1/2-y,-x,1/2+z'
166+
'1/2-y,1/2-x,z'
167+
'-z,1/2-y,1/2+x'
168+
'1/2-z,-y,1/2+x'
169+
'1/2-z,1/2-y,x'
170+
'-x,1/2-y,1/2-z'
171+
'1/2-x,-y,1/2-z'
172+
'1/2-x,1/2-y,-z'
173+
'-y,1/2-z,1/2-x'
174+
'1/2-y,-z,1/2-x'
175+
'1/2-y,1/2-z,-x'
176+
'-z,1/2-x,1/2-y'
177+
'1/2-z,-x,1/2-y'
178+
'1/2-z,1/2-x,-y'
179+
'-x,1/2-z,1/2-y'
180+
'1/2-x,-z,1/2-y'
181+
'1/2-x,1/2-z,-y'
182+
'-y,1/2-x,1/2-z'
183+
'1/2-y,-x,1/2-z'
184+
'1/2-y,1/2-x,-z'
185+
'-z,1/2-y,1/2-x'
186+
'1/2-z,-y,1/2-x'
187+
'1/2-z,1/2-y,-x'
188+
'-x,1/2+y,1/2+z'
189+
'1/2-x,y,1/2+z'
190+
'1/2-x,1/2+y,z'
191+
'-y,1/2+z,1/2+x'
192+
'1/2-y,z,1/2+x'
193+
'1/2-y,1/2+z,x'
194+
'-z,1/2+x,1/2+y'
195+
'1/2-z,x,1/2+y'
196+
'1/2-z,1/2+x,y'
197+
'-x,1/2+z,1/2+y'
198+
'1/2-x,z,1/2+y'
199+
'1/2-x,1/2+z,y'
200+
'-y,1/2+x,1/2+z'
201+
'1/2-y,x,1/2+z'
202+
'1/2-y,1/2+x,z'
203+
'-z,1/2+y,1/2+x'
204+
'1/2-z,y,1/2+x'
205+
'1/2-z,1/2+y,x'
206+
'x,1/2-y,1/2+z'
207+
'1/2+x,-y,1/2+z'
208+
'1/2+x,1/2-y,z'
209+
'y,1/2-z,1/2+x'
210+
'1/2+y,-z,1/2+x'
211+
'1/2+y,1/2-z,x'
212+
'z,1/2-x,1/2+y'
213+
'1/2+z,-x,1/2+y'
214+
'1/2+z,1/2-x,y'
215+
'x,1/2-z,1/2+y'
216+
'1/2+x,-z,1/2+y'
217+
'1/2+x,1/2-z,y'
218+
'y,1/2-x,1/2+z'
219+
'1/2+y,-x,1/2+z'
220+
'1/2+y,1/2-x,z'
221+
'z,1/2-y,1/2+x'
222+
'1/2+z,-y,1/2+x'
223+
'1/2+z,1/2-y,x'
224+
'x,1/2+y,1/2-z'
225+
'1/2+x,y,1/2-z'
226+
'1/2+x,1/2+y,-z'
227+
'y,1/2+z,1/2-x'
228+
'1/2+y,z,1/2-x'
229+
'1/2+y,1/2+z,-x'
230+
'z,1/2+x,1/2-y'
231+
'1/2+z,x,1/2-y'
232+
'1/2+z,1/2+x,-y'
233+
'x,1/2+z,1/2-y'
234+
'1/2+x,z,1/2-y'
235+
'1/2+x,1/2+z,-y'
236+
'y,1/2+x,1/2-z'
237+
'1/2+y,x,1/2-z'
238+
'1/2+y,1/2+x,-z'
239+
'z,1/2+y,1/2-x'
240+
'1/2+z,y,1/2-x'
241+
'1/2+z,1/2+y,-x'
242+
243+
loop_
244+
_atom_type_symbol
245+
_atom_type_oxidation_number
246+
Na1+ 1.000
247+
Cl1- -1.000
248+
249+
loop_
250+
_atom_site_label
251+
_atom_site_type_symbol
252+
_atom_site_symmetry_multiplicity
253+
_atom_site_Wyckoff_symbol
254+
_atom_site_fract_x
255+
_atom_site_fract_y
256+
_atom_site_fract_z
257+
_atom_site_occupancy
258+
_atom_site_attached_hydrogens
259+
_atom_site_calc_flag
260+
Na1 Na1+ 4 a 0. 0. 0. 1. 0 d
261+
Cl1 Cl1- 4 b 0.5 0.5 0.5 1. 0 d
262+
263+
_refine_ls_R_factor_all 0.022
264+
265+
266+
267+
_cod_database_code 1000041

cmi_scripts/calcbvsnacl/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Calculate bond valence sums for NaCl
2+
3+
This example shows how to evaluate bond valence sums using the `diffpy.srreal`
4+
module in DiffPy-CMI. BVS calculator uses a standard set of bond valence
5+
parameters obtained from a lookup table. Bond valence parameters can be
6+
set to custom values. Multiple BVS calculator objects can be created,
7+
where each one has separate lookup table and optionally different valence
8+
parameters.

cmi_scripts/calcbvsnacl/calcbvs.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
'''Calculation of bond valence sums using diffpy.srreal module included in
5+
DiffPy-CMI.
6+
'''
7+
8+
from diffpy.Structure import loadStructure
9+
from diffpy.srreal.bvscalculator import BVSCalculator
10+
11+
# load crystal structure data from a CIF file
12+
nacl = loadStructure('NaCl.cif')
13+
14+
# create bond valence sum calculator object
15+
bvsc = BVSCalculator()
16+
17+
# calculate BVS and print the expected and actual valences
18+
vsim = bvsc(nacl)
19+
print 'Calculate bond valence sums for NaCl "bvsc(nacl)"'
20+
print 'expected "bvsc.valences":\n ', bvsc.valences
21+
print 'calculated "bvsc.value":\n ' , vsim
22+
print 'difference "bvsc.bvdiff":\n ', bvsc.bvdiff
23+
print 'root mean square difference "bvsc.bvrmsdiff":', bvsc.bvrmsdiff
24+
print
25+
26+
# create new BVS calculator with a custom bond valence parameters
27+
bvsc2 = BVSCalculator()
28+
29+
# Use alternate value for the Na+ Cl- bond valence parameters from
30+
# http://www.iucr.org/__data/assets/file/0018/59004/bvparm2011.cif
31+
# These parameters have 6A cutoff.
32+
bvsc2.bvparamtable.setCustom('Na', +1, 'Cl', -1, Ro=1.6833, B=0.608)
33+
bvsc2.rmax = 6
34+
print "BVS in NaCl with alternate parameters:\n ", bvsc2(nacl)
35+
print
36+
37+
# Lookup table of bond valence parameters can be used as separate object.
38+
from diffpy.srreal.bvparameterstable import BVParametersTable
39+
40+
table = BVParametersTable()
41+
bp = table.lookup('Na+', 'Cl-')
42+
bp2 = table.lookup('Na', +1, 'Br', -1)
43+
print "Standard lookup of bond valence parameters:"
44+
print " ", bp
45+
print " ", bp2
46+
print
47+
48+
print "Handling of unknown or invalid ion pairs:"
49+
print " table.lookup('A+', 'X-'):", table.lookup('A+', 'X-')
50+
print " table.lookup('A+', 'X-') == table.none():", (
51+
table.lookup('A+', 'X-') == table.none())

0 commit comments

Comments
 (0)