Sample¶
This is a python object that is the main wrapper for all of the methods of pyMACS. It requires only a few details to initialize - a .cif file to specify the sample being simulated, and a few instrumental settings.
- class pyMACS.sample.Sample(a=6.28, b=6.28, c=6.28, alpha=90.0, beta=90.0, gamma=90.0, cell_vol=None, V_recip=None, name='default_sample', sample_shape='cylinder', sample_diameter_d=0.02, sample_tilt=60.0, sample_length=0.04, sample_widx=0.003, sample_widy=0.003, sample_widz=0.003, symm_ops=None, space_group=None, ciffile=None, laufile=None, customlaufile=None, b_arr=False, orient_u=[1, 0, 0], orient_v=[0, 1, 0], orient_w=[0, 0, 1], rho_abs_fu=False, rho_abs=False, sigma_inc=False, sample_mosaic=30.0, delta_d=0.0005, abs_dict=False, crystal_axis_xrot=45.0, crystal_axis_yrot=0.0, crystal_axis_zrot=-15.0, scattering_definition=False, geometry_definition=False)¶
Bases:
object
The purpose of this class is to perform operations related to intrinsic sample properties that will ultimately be simulated. It contains information regarding the sample itself as well as its orientaion, and methods to calculate crystallographic quantities.
- Parameters:
a (float) – Length of lattice vector in a-direction (Ang)
b (float) – Length of lattice vector in b-direction (Ang)
c (float) – length of lattice vector in c-direction (Ang)
alpha (float) – Lattice alpha angle (deg)
beta (float) – Lattice beta angle (deg)
gamma (float) – Lattice gamma angle (deg)
name (str) – Name assosciated with the sample.
astar (np.ndarray of len 3) – Reciprocal lattice vector astarin Ang^-1. Calculated from direct lattice and should not be input.
bstar (np.ndarray of len 3) – Reciprocal lattice vector bstar in Ang^-1. Calculated from direct lattice and should not be input.
cstar (np.ndarray of len 3) – Reciprocal lattice vector cstar in Ang^-1. Calculated from direct lattice and should not be input
avec (np.ndarray of len 3) – Direct lattice vector a in Ang. Calculated from lattice specification and should not be input.
bvec (np.ndarray of len 3) – Direct lattice vector b in Ang. Calculated from lattice specification and should not be input.
cvec (np.ndarray of len 3) – Direct lattice vector c in Ang. Calculated from lattice specification and should not be input.
cell_vol (float) – Direct unit cell volume in Ang^3, again calculated.
cell_vol_recip (float) – Recriprocal unit cell volume in Ang^-1, calculated.
sample_shape (str) – Sample shape which also affects many parts of the simulation. The allowed values for this are the following (‘box’,’cylinder’,’powder’,’spot_box’,’spot_cylinder’,’box_inel_crystal’). The first three simulate only elastic scattering with their respective geometries. The spot_box and spot_cylinder components are effectively powders with a delta function in Q and energy. Finally, the box_inel_crystal shape allows for the insertion of a delta function at arbitrary points in Q-E space.
sample_diameter_d (float) – For cylinder shape, the diameter
sample_tilt (float) – Tilt of cylinder from the vertical axis, with 0 being vertical and the rotation axis being the x-axis or perpendicular to the beam. In degrees.
sample_length (float) – Length of cylinder geometry in m.
sample_widx (float) – Box geometry width in the x-direction in m.
sample_widy (float) – Box geometry width in the y-direction in m.
sample_widz (float) – Box geometry width in the z-direction in m.
ciffile (str) – Cif file assosciated with sample initialization.
b_arr (dict) – Scattering lengths of ions in sample. Usually extracted from built in NIST tables.
scattering_def (mcstasscript_instrument) – McStas script instrument containing the relevant UNION scattering process from which the trace will be extracted in the final instrument file. See example for how to build this.
geometry_def (mcstasscript_instrument) – Mcstasscript instrument containing the relevant UNION geometry objects that define the sample environment.
- QE_to_twotheta(Qmag, Ei, omega, mode='deg')¶
Given HKL indices, incident energy, and energy transfer, returns the scattering angle
- Parameters:
Qmag (float) – Input Q-magnitude in Ang^-1
Ei (float) – Incident neutron energy in meV
omega (float) – Neutron energy transfer at sample in meV
mode – Determines if angle is returned in degrees or radians. Allowed values ‘deg’ or ‘rad’.
- Return twoTheta:
Neutron scattering angle in (deg/rad)
- Return type:
float
- Qmag_HKL(H, K, L)¶
For a specfied reflection in H, K, L, returns the magnitude of its momentum transfer.
- Parameters:
H (int / float) – H-index of reflection. (rlu)
K (int / float) – K-index of reflection. (rlu)
L (int / float) – L-index of reflection. (rlu)
- Return qmag:
Structure factor squared (barn)
- Return type:
float
- cif2lau(outdir='/home/runner/work/pyMACS/pyMACS/docs/source', launame=None)¶
Converts input cif file to a Crystallographica format .lau file. Not intended for users.
- fetch_F_HKL(H, K, L)¶
For a specified reflection in H, K, L, returns a squared structure factor.
- Parameters:
H (int / float) – H-index of reflection. (rlu)
K (int / float) – K-index of reflection. (rlu)
L (int / float) – L-index of reflection. (rlu)
- Return F:
Structure factor squared (barn)
- Return type:
float
- gen_reflection_list(max_tau=20, maxQmag=10000000000.0, b_dict=False)¶
Calculates the structure factor for all reflections in the unit cell up to some maximum momentum transfer.
- Parameters:
max_tau (int) – Maximum index (doesn’t matter which) allowed for reflection generation. Default is 20.
maxQmag (float) – Alternate way to specify maximum allowed reflection, maximum momentum transfer in Ang^-1.
- Return tau:
List of reflections in a matrix with columns [H K L S(Q)^2] where S(Q)^2 is the structure factor. Structure factors account for multiplicity.
- Return type:
np.ndarray
- gen_unique_coords()¶
Generates the unique coordinates in the unit cell in fractional coordinates. Uses symmetry operations as specified in cif file.
- Return coords:
Returns a dictionary of coordinates with columns [ion,label,x,y,z,occupancy,thermal_dispacement,Uiso,site_multiplicity] Here, x,y,z are the coordinates in fractional coordinates and ‘ion’ refers to the element.
- Return type:
dict
- gen_unit_cell_positions()¶
Generates the coordinates of ions in the unit cell in fractional coordinates.
- Return structure array:
Returns a numpy array with coulmns of [ion, b_elastic, x, y, z, occupancy]. Here ion refers to the ion name and b_elastic is the elastic scattering cross section.
- Return type:
dict
- generate_symmetry_operations()¶
Extracts the symmetry operations from the stored cif file.
- Return symm_arr:
List of symmetry operations in format of [x,y,z]
- Return type:
list
- project_sample_realspace()¶
Given an alignment in the objects orient_u and orient_v, with u being perpendicular to beam and v parallel to beam Used to write instr file, where convention is that x is perpendicular to beam, z is beam direction, y is vertical.
- twotheta_hkl(H, K, L, E, mode='deg')¶
For a specfied reflection in H, K, L, and incident energy, returns the scattering angle.
- Parameters:
H (int / float) – H-index of reflection. (rlu)
K (int / float) – K-index of reflection. (rlu)
L (int / float) – L-index of reflection. (rlu)
E (float) – Incident neutron energy. (meV)
mode (str) – Specifies if angle should be returned in radians or degrees. Allowed values are ‘deg’ and ‘rad’.
- Return twoTheta:
Scattering angle (degrees / rad)
- Return type:
float
- twotheta_hkl_omega(H, K, L, Ei, omega, mode='deg')¶
For a specfied reflection in H, K, L, and incident energy, and energy transfer returns the scattering angle.
- Parameters:
H (int / float) – H-index of reflection. (rlu)
K (int / float) – K-index of reflection. (rlu)
L (int / float) – L-index of reflection. (rlu)
Ei (float) – Incident neutron energy. (meV)
omega (float) – Neutron energy transfer at sample. (meV)
- Return twoTheta:
Scattering angle (degrees / rad)
- Return type:
float
Create a list of object parameters, like n_mono.