Skip to content

Commit

Permalink
muon_find_equiv -> find_equiv, and related tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bonfus committed May 20, 2016
1 parent 8818e7c commit 4a15440
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
6 changes: 3 additions & 3 deletions docs/Tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ can be specified as
If proper symmetry of the sample is present in the sample definition, it
is usually usefull to get symmetry equivalent sites.
This can be done with the utility function :py:func:`~muesr.utilities.muon.muon_find_equiv`.
This can be done with the utility function :py:func:`~muesr.utilities.muon.find_equiv`.

.. code-block:: python
>>> from muesr.utilities.muon import muon_find_equiv
>>> muon_find_equiv(mysample)
>>> from muesr.utilities.muon import find_equiv
>>> find_equiv(mysample)
Defining a magnetic structure
Expand Down
9 changes: 9 additions & 0 deletions docs/Usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This is very easy! You just do: ::

the :py:attr:`~muesr.core.sample.Sample.name` property is optional.


Defining a lattice structure
----------------------------

Expand Down Expand Up @@ -224,6 +225,14 @@ Useful readings
- http://www.neutron-sciences.org/articles/sfn/pdf/2014/01/sfn201402001.pdf


Setting the muon position
-------------------------

The muon position can be easly set with the .

If symmetry is defined, equivalent muon positions can be obtained with
the function :py:func:`~muesr.utilities.muon.find_equiv`

Calculate local fields
------------------------

Expand Down
11 changes: 5 additions & 6 deletions examples/LaFeAsO/run_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from muesr.core.sample import Sample
from muesr.io.cif.cif import load_mcif
from muesr.utilities.symsearch import sym_search
from muesr.utilities.muon import muon_find_equiv
from muesr.utilities.symsearch import symsearch
from muesr.utilities.muon import find_equiv
from muesr.engines.clfc import locfield

#define an empty sample.
Expand All @@ -24,12 +24,11 @@
# these are inspected from the structure rather than parsed from the cif.
# The reason for doing this is that structure may be read from files
# without symmetry informations.
sym_search(m)
symsearch(m)
# Sets muon position in fractional coordinates
m.add_muon([0.375, 0.375, 0.635])
# Find crystalographically equivalent muon sites. Uses 3 decimal rounding
# to check if two positions are equivalent.
muon_find_equiv(m)
# Find crystalographically equivalent muon sites.
find_equiv(m)
res=locfield(m, 's',[100,100,50],200)
print('Structure in file: '+mcif)
for e in res:
Expand Down
10 changes: 5 additions & 5 deletions muesr/tests/utilities/test_muon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from muesr.core.sampleErrors import CellError, MuonError
from muesr.core.sample import Sample
from muesr.utilities.muon import muon_set_frac, muon_find_equiv, muon_reset
from muesr.utilities.muon import muon_set_frac, find_equiv, muon_reset
from muesr.io.cif.cif import read_cif

co_lattice = StringIO("""
Expand Down Expand Up @@ -314,7 +314,7 @@ def test_muon_reset(self):
muon_set_frac(self._sample, "0.125 0.125 0.125")
np.testing.assert_array_almost_equal(np.array([0.125,0.125,0.125]),self._sample.muons[1])

def test_muon_find_equiv(self):
def test_find_equiv(self):
# ugly way to load a lattice with its symetry
co_lattice.seek(0)
atoms, sym = read_cif(co_lattice,0) # selectd index 0
Expand All @@ -328,10 +328,10 @@ def test_muon_find_equiv(self):

#tests throw error if no muon positions defined
with self.assertRaises(MuonError):
muon_find_equiv(self._sample)
find_equiv(self._sample)

muon_set_frac(self._sample, "0 0 0")
muon_find_equiv(self._sample)
find_equiv(self._sample)

muon_positions = self._sample.muons

Expand All @@ -342,7 +342,7 @@ def test_muon_find_equiv(self):
self._sample._reset(muon=True)

muon_set_frac(self._sample, "0.2 0.3 0.4")
muon_find_equiv(self._sample)
find_equiv(self._sample)

muon_positions = self._sample.muons
#positions calculated with VESTA
Expand Down
8 changes: 4 additions & 4 deletions muesr/utilities/ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def mago_set_k(sample, kvalue=None,mm=None):
return


def mago_add(sample, inputConvention='b-c'):
def mago_add(sample, coordinates='b-c'):
"""
Add a magnetic model (fourier components and K vector).
Fourier components are in CARTESIAN coordinates.
The order is automatically selected if succesfully added.
Expand All @@ -65,7 +65,7 @@ def mago_add(sample, inputConvention='b-c'):
nmm = MM(sample.cell.get_number_of_atoms(),sample.cell.get_cell())

mago_set_k(sample, mm=nmm)
mago_set_FC(sample, mm=nmm, inputConvention=inputConvention)
mago_set_FC(sample, mm=nmm, inputConvention=coordinates)
sample.mm = nmm


Expand Down Expand Up @@ -94,7 +94,7 @@ def mago_set_FC(sample, fcs= None, atoms_types = None, mm=None, inputConvention=
nprint('Magnetic moments in bohr magnetons and cartesian coordinates.')
inputConvEnum = 0

elif inputConvention.lower() in ['bohr/angstrom-lattic', 'b/a-l']:
elif inputConvention.lower() in ['bohr/angstrom-lattice', 'b/a-l']:
nprint('Magnetic moments in bohr magnetons/angstrom and lattice coordinates.')
inputConvEnum = 1

Expand Down
2 changes: 1 addition & 1 deletion muesr/utilities/muon.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def muon_set_frac(sample, arg = None):



def muon_find_equiv(sample, eps=1.e-3):
def find_equiv(sample, eps=1.e-3):
"""
Given the unit cell symmetry, finds the equivalent muon sites.
Magnetic order is NOT considered
Expand Down

0 comments on commit 4a15440

Please sign in to comment.