Skip to content

Commit

Permalink
Merge e8d408b into d06f4af
Browse files Browse the repository at this point in the history
  • Loading branch information
MSallermann authored Mar 20, 2019
2 parents d06f4af + e8d408b commit ec8224e
Show file tree
Hide file tree
Showing 17 changed files with 291 additions and 325 deletions.
4 changes: 4 additions & 0 deletions core/docs/INPUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ A lattice constant can be used for scaling:
### Scaling constant
lattice_constant 1.0
```
Note that it scales the Bravais vectors and therefore the
translations, atom positions in the basis cell and potentially
-- if you specified them in terms of the Bravais vectors --
also the anisotropy and DM vectors.


Heisenberg Hamiltonian <a name="Heisenberg"></a>
Expand Down
14 changes: 2 additions & 12 deletions core/docs/c-api/Geometry.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Geometry_Set_Cell_Atoms(State *state, int n_atoms, float ** atoms)
```
Set the number and positions of atoms in a basis cell.
Positions are in units of the bravais vectors.
Positions are in units of the bravais vectors (scaled by the lattice constant).
Expand Down Expand Up @@ -175,16 +175,6 @@ Get bravais vectors ta, tb, tc.



### Geometry_Get_Translation_Vectors

```C
void Geometry_Get_Translation_Vectors(State *state, float ta[3], float tb[3], float tc[3], int idx_image=-1, int idx_chain=-1)
```
Get translation vectors ta, tb, tc.
### Geometry_Get_Dimensionality

```C
Expand Down Expand Up @@ -245,7 +235,7 @@ Get number of atoms in a basis cell.
int Geometry_Get_Cell_Atoms(State *state, scalar ** atoms, int idx_image=-1, int idx_chain=-1)
```

Get basis cell atoms.
Get basis cell atom positions in units of the bravais vectors (scaled by the lattice constant).



Expand Down
9 changes: 2 additions & 7 deletions core/include/Spirit/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PREFIX void Geometry_Set_N_Cells(State * state, int n_cells[3]) SUFFIX;

/*
Set the number and positions of atoms in a basis cell.
Positions are in units of the bravais vectors.
Positions are in units of the bravais vectors (scaled by the lattice constant).
*/
PREFIX void Geometry_Set_Cell_Atoms(State *state, int n_atoms, float ** atoms) SUFFIX;

Expand Down Expand Up @@ -126,11 +126,6 @@ Get bravais vectors ta, tb, tc.
*/
PREFIX void Geometry_Get_Bravais_Vectors(State *state, float a[3], float b[3], float c[3], int idx_image=-1, int idx_chain=-1) SUFFIX;

/*
Get translation vectors ta, tb, tc.
*/
PREFIX void Geometry_Get_Translation_Vectors(State *state, float ta[3], float tb[3], float tc[3], int idx_image=-1, int idx_chain=-1) SUFFIX;

/*
Retrieve dimensionality of the system (0, 1, 2, 3).
*/
Expand Down Expand Up @@ -161,7 +156,7 @@ Get number of atoms in a basis cell.
PREFIX int Geometry_Get_N_Cell_Atoms(State *state, int idx_image=-1, int idx_chain=-1) SUFFIX;

/*
Get basis cell atoms.
Get basis cell atom positions in units of the bravais vectors (scaled by the lattice constant).
*/
PREFIX int Geometry_Get_Cell_Atoms(State *state, scalar ** atoms, int idx_image=-1, int idx_chain=-1) SUFFIX;

Expand Down
19 changes: 1 addition & 18 deletions core/python/spirit/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def get_bravais_lattice_type(p_state, idx_image=-1, idx_chain=-1):
ctypes.c_int, ctypes.c_int]
_Get_Bravais_Vectors.restype = None
def get_bravais_vectors(p_state, idx_image=-1, idx_chain=-1):
"""Get the bravais vectors.
"""Get the Bravais vectors.
Returns three arrays of shape (3).
"""
Expand All @@ -154,23 +154,6 @@ def get_n_cells(p_state, idx_image=-1, idx_chain=-1):
_Get_N_Cells(ctypes.c_void_p(p_state), n_cells, ctypes.c_int(idx_image), ctypes.c_int(idx_chain))
return [n for n in n_cells]

_Get_Translation_Vectors = _spirit.Geometry_Get_Translation_Vectors
_Get_Translation_Vectors.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_float),
ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
ctypes.c_int, ctypes.c_int]
_Get_Translation_Vectors.restype = None
def get_translation_vectors(p_state, idx_image=-1, idx_chain=-1):
"""Get the translation vectors in global coordinates.
Returns three arrays of shape (3).
"""
ta = (3*ctypes.c_float)()
tb = (3*ctypes.c_float)()
tc = (3*ctypes.c_float)()
_Get_Translation_Vectors(ctypes.c_void_p(p_state), ta, tb, tc,
ctypes.c_int(idx_image), ctypes.c_int(idx_chain))
return [a for a in ta], [b for b in tb], [c for c in tc]

_Get_Dimensionality = _spirit.Geometry_Get_Dimensionality
_Get_Dimensionality.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int]
_Get_Dimensionality.restype = ctypes.c_int
Expand Down
25 changes: 9 additions & 16 deletions core/python/test/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
p_state = state.setup(cfgfile) # State setup

class TestParameters(unittest.TestCase):

def setUp(self):
''' Setup a p_state and copy it to Clipboard'''
self.p_state = p_state

class Geometry(TestParameters):

def test_bounds(self):
minb, maxb = geometry.get_bounds(self.p_state)
# From the api.cfg the space is 2:2:1 particles
Expand All @@ -32,14 +32,14 @@ def test_bounds(self):
self.assertEqual(maxb[0], 1)
self.assertEqual(maxb[1], 1)
self.assertEqual(maxb[2], 0)

def test_center(self):
center = geometry.get_center(self.p_state)
# From the api.cfg the space is 2:2:1 particles
self.assertEqual(center[0], 0.5)
self.assertEqual(center[1], 0.5)
self.assertEqual(center[2], 0)

def test_bravais_vector(self):
a, b, c = geometry.get_bravais_vectors(self.p_state)
# From the api.cfg the bravais vectors are (1,0,0), (0,1,0), (0,0,1)
Expand All @@ -48,24 +48,17 @@ def test_bravais_vector(self):
# Check also that the bravais lattice type matches simple cubic
lattice_type = geometry.get_bravais_lattice_type(self.p_state)
self.assertEqual(lattice_type, geometry.BRAVAIS_LATTICE_SC)

def test_N_cells(self):
ncells = geometry.get_n_cells(self.p_state)
self.assertEqual(ncells[0], 2)
self.assertEqual(ncells[1], 2)
self.assertEqual(ncells[2], 1)

def test_translational_vector(self):
ta, tb, tc = geometry.get_translation_vectors(self.p_state)
# From the api.cfg the tvec are (1,0,0), (0,1,0), (0,0,1)
self.assertEqual(ta[0], tb[1])
self.assertEqual(ta[1], tb[2])



def test_dimensionality(self):
dim = geometry.get_dimensionality(self.p_state)
self.assertEqual(dim, 2)

def test_positions(self):
positions = geometry.get_positions(self.p_state)
# spin at (0,0,0)
Expand All @@ -84,7 +77,7 @@ def test_positions(self):
self.assertAlmostEqual(positions[3][0], 1)
self.assertAlmostEqual(positions[3][1], 1)
self.assertAlmostEqual(positions[3][2], 0)

def test_atom_types(self):
types = geometry.get_atom_types(self.p_state)
self.assertEqual(len(types), 4)
Expand Down
Loading

0 comments on commit ec8224e

Please sign in to comment.