@@ -67,8 +67,11 @@ view to the data in C++ class. Do not resize or reshape.\n\
6767const char * doc_Atom_init_copy = " \
6868Make a deep copy of an existing Atom.\n \
6969" ;
70- const char * doc_Atom_xic = " Vector element in xyz_cartn" ;
71- const char * doc_Atom_uijc = " Matrix element in uij_cartn" ;
70+ const char * doc_Atom_xic = " Vector element in xyz_cartn." ;
71+ const char * doc_Atom_occ = " Fractional occupancy of this atom." ;
72+ const char * doc_Atom_anisotropy =
73+ " Boolean flag for anisotropic displacements." ;
74+ const char * doc_Atom_uijc = " Matrix element in uij_cartn." ;
7275
7376// class AtomicStructureAdapter
7477
@@ -270,28 +273,55 @@ void set_uij_cartn(Atom& a, object& value)
270273}
271274
272275
273- double get_xc (const Atom& a) { return a.xyz_cartn [0 ]; }
274- void set_xc (Atom& a, double value) { a.xyz_cartn [0 ] = value; }
275- double get_yc (const Atom& a) { return a.xyz_cartn [1 ]; }
276- void set_yc (Atom& a, double value) { a.xyz_cartn [1 ] = value; }
277- double get_zc (const Atom& a) { return a.xyz_cartn [2 ]; }
278- void set_zc (Atom& a, double value) { a.xyz_cartn [2 ] = value; }
279-
280- double get_uc11 (const Atom& a) { return a.uij_cartn (0 , 0 ); }
281- void set_uc11 (Atom& a, double value) { a.uij_cartn (0 , 0 ) = value; }
282- double get_uc22 (const Atom& a) { return a.uij_cartn (1 , 1 ); }
283- void set_uc22 (Atom& a, double value) { a.uij_cartn (1 , 1 ) = value; }
284- double get_uc33 (const Atom& a) { return a.uij_cartn (2 , 2 ); }
285- void set_uc33 (Atom& a, double value) { a.uij_cartn (2 , 2 ) = value; }
286- double get_uc12 (const Atom& a) { return a.uij_cartn (0 , 1 ); }
287- void set_uc12 (Atom& a, double value) {
288- a.uij_cartn (0 , 1 ) = a.uij_cartn (1 , 0 ) = value; }
289- double get_uc13 (const Atom& a) { return a.uij_cartn (0 , 2 ); }
290- void set_uc13 (Atom& a, double value) {
291- a.uij_cartn (0 , 2 ) = a.uij_cartn (2 , 0 ) = value; }
292- double get_uc23 (const Atom& a) { return a.uij_cartn (1 , 2 ); }
293- void set_uc23 (Atom& a, double value) {
294- a.uij_cartn (1 , 2 ) = a.uij_cartn (2 , 1 ) = value; }
276+ template <const int i>
277+ double get_xyz (const Atom& a)
278+ {
279+ return a.xyz_cartn [i];
280+ }
281+
282+ template <const int i>
283+ void set_xyz (Atom& a, object value)
284+ {
285+ a.xyz_cartn [i] = extractdouble (value);
286+ }
287+
288+
289+ double get_occ (const Atom& a)
290+ {
291+ return a.occupancy ;
292+ }
293+
294+ void set_occ (Atom& a, object value)
295+ {
296+ a.occupancy = extractdouble (value);
297+ }
298+
299+
300+ bool get_anisotropy (const Atom& a)
301+ {
302+ return a.anisotropy ;
303+ }
304+
305+ void set_anisotropy (Atom& a, object value)
306+ {
307+ a.anisotropy = bool (value);
308+ }
309+
310+
311+ template <const int i, const int j>
312+ double get_uc (const Atom& a)
313+ {
314+ assert (i <= j);
315+ return a.uij_cartn (i, j);
316+ }
317+
318+ template <const int i, const int j>
319+ void set_uc (Atom& a, object value)
320+ {
321+ assert (i <= j);
322+ a.uij_cartn (i, j) = extractdouble (value);
323+ if (i != j) a.uij_cartn (j, i) = a.uij_cartn (i, j);
324+ }
295325
296326// template wrapper class for overloading of clone and _customPQConfig
297327
@@ -524,20 +554,21 @@ void wrap_AtomicStructureAdapter()
524554 .add_property (" xyz_cartn" ,
525555 atom_class.attr (" _get_xyz_cartn" ),
526556 set_xyz_cartn)
527- .add_property (" xc" , get_xc, set_xc, doc_Atom_xic)
528- .add_property (" yc" , get_yc, set_yc, doc_Atom_xic)
529- .add_property (" zc" , get_zc, set_zc, doc_Atom_xic)
530- .def_readwrite (" occupancy" , &Atom::occupancy)
531- .def_readwrite (" anisotropy" , &Atom::anisotropy)
557+ .add_property (" xc" , get_xyz<0 >, set_xyz<0 >, doc_Atom_xic)
558+ .add_property (" yc" , get_xyz<1 >, set_xyz<1 >, doc_Atom_xic)
559+ .add_property (" zc" , get_xyz<2 >, set_xyz<2 >, doc_Atom_xic)
560+ .add_property (" occupancy" , get_occ, set_occ, doc_Atom_occ)
561+ .add_property (" anisotropy" , get_anisotropy, set_anisotropy,
562+ doc_Atom_anisotropy)
532563 .add_property (" uij_cartn" ,
533564 atom_class.attr (" _get_uij_cartn" ),
534565 set_uij_cartn)
535- .add_property (" uc11" , get_uc11, set_uc11 , doc_Atom_uijc)
536- .add_property (" uc22" , get_uc22, set_uc22 , doc_Atom_uijc)
537- .add_property (" uc33" , get_uc33, set_uc33 , doc_Atom_uijc)
538- .add_property (" uc12" , get_uc12, set_uc12 , doc_Atom_uijc)
539- .add_property (" uc13" , get_uc13, set_uc13 , doc_Atom_uijc)
540- .add_property (" uc23" , get_uc23, set_uc23 , doc_Atom_uijc)
566+ .add_property (" uc11" , get_uc< 0 , 0 >, set_uc< 0 , 0 > , doc_Atom_uijc)
567+ .add_property (" uc22" , get_uc< 1 , 1 >, set_uc< 1 , 1 > , doc_Atom_uijc)
568+ .add_property (" uc33" , get_uc< 2 , 2 >, set_uc< 2 , 2 > , doc_Atom_uijc)
569+ .add_property (" uc12" , get_uc< 0 , 1 >, set_uc< 0 , 1 > , doc_Atom_uijc)
570+ .add_property (" uc13" , get_uc< 0 , 2 >, set_uc< 0 , 2 > , doc_Atom_uijc)
571+ .add_property (" uc23" , get_uc< 1 , 2 >, set_uc< 1 , 2 > , doc_Atom_uijc)
541572 .def_pickle (SerializationPickleSuite<Atom,DICT_IGNORE>())
542573 ;
543574
0 commit comments