7. structurefactor (sf)

Structure factors and directly related functions for scattering related to interaction potentials between particles.

Return values are dataArrays were useful.

To get only Y values use .Y

For RMSA an improved algorithm is used based on the original idea (see Notes in RMSA).

7.1. Structure Factors

RMSA(q, R, scl, gamma[, molarity, eta, useHP]) Structure factor for a screened coulomb interaction in rescaled mean spherical approximation (RMSA).
PercusYevick(q, R[, molarity, eta]) The Percus-Yevick structure factor.
PercusYevick1D(q[, R, eta]) The PercusYevick structure factor in 1D
PercusYevick2D(q[, R, eta, a]) The PercusYevick structure factor in 2D
stickyHardSphere(q, R, width, depth[, …]) Structure factor of a square well potential with depth and width (sticky hard spheres).
adhesiveHardSphere(q, R, tau, delta[, …]) structure factor of a adhesive hard sphere potential (a square well potential)
criticalSystem(q, corrlength, isothermalcompress) Structure factor of a critical system should take the Ornstein-Zernike form.
latticeStructureFactor(q[, lattice, …]) Radial structure factor S(q) in powder average of a crystal lattice with particle asymmetry, DebyeWaller factor, diffusive scattering and broadening due to domain size.
orientedLatticeStructureFactor(qxyz, lattice) 2D structure factor S(q) of an oriented crystal lattice including particle asymmetry, DebyeWaller factor, diffusive scattering, domain rotation and domain size.
radialorientedLSF(*args, **kwargs) Radial averaged structure factor S(q) of an oriented crystal lattice calculated as orientedLatticeStructureFactor.

7.2. Hydrodynamics

hydrodynamicFunct(wavevector, Rh, molarity) Hydrodynamic function H(q) from hydrodynamic pair interaction of spheres in suspension.

7.3. Pair Correlation

sq2gr(Sq, R[, interpolatefactor]) Radial distribution function g(r) from structure factor Sq.

7.4. Lattice

Lattices with specific structure :

3D

bravaisLattice(latticeVectors, size[, b]) Create a Bravais lattice.
scLattice(abc, size[, b]) Simple Cubic lattice.
bccLattice(abc, size[, b]) Body centered cubic lattice.
fccLattice(abc, size[, b]) Face centered cubic lattice.
hcpLattice(ab, size[, b]) Hexagonal closed packed lattice.
diamondLattice(abc, size[, b]) Diamond cubic lattice with 8 atoms in unit cell.
rhombicLattice(latticeVectors, size[, …]) Create a rhombic lattice with specified unit cell atoms.
pseudoRandomLattice(size, numberOfPoints[, …]) Create a lattice with a pseudo random distribution of points.

2D

sqLattice(ab, size[, b]) Simple 2D square lattice.
hexLattice(ab, size[, b]) Simple 2D hexagonal lattice.

1D

lamLattice(a, size[, b]) 1D lamellar lattice.

lattice methods :

lattice.X X coordinates
lattice.Y Y coordinates
lattice.Z Z coordinates
lattice.XYZ X,Y,Z coordinates array Nx3
lattice.b Scattering length
lattice.array Coordinates and scattering length as array
lattice.points Points with scattering length >0
lattice.set_b(b) Set all initial points to given scattering length.
lattice.type Returns type of the lattice
lattice.move(vector) Move all points by vector.
lattice.centerOfMass() Center of mass as center of geometry.
lattice.numberOfAtoms() Number of Atoms
lattice.show([R, cmap, fig, ax]) Show the lattice in matplotlib with scattering length color coded.
lattice.filter(funktion) Set lattice points scattering length according to a function.
lattice.planeSide(vector[, center, b, invert]) Set scattering length for points on one side of a plane.
lattice.inSphere(R[, center, b, invert]) Set scattering length for points in sphere.
lattice.inParallelepiped(v1, v2, v3[, …]) Set scattering length for points in parallelepiped.
rhombicLattice.unitCellAtomPositions Absolute positions of unit cell atoms.
rhombicLattice.getReciprocalLattice([size]) Reciprocal lattice of given size with peak scattering intensity.
rhombicLattice.getRadialReciprocalLattice(size) Get radial distribution of Bragg peaks with structure factor and multiplicity.
rhombicLattice.rotatePlane2hkl(plane, hkl) Rotate plane points that plane is perpendicular to hkl direction.
rhombicLattice.rotatePlaneAroundhkl(plane, …) Rotate plane points around hkl direction.
rhombicLattice.rotatehkl2Vector(hkl, vector) Rotate lattice that hkl direction is parallel to vector.
rhombicLattice.rotateAroundhkl(hkl[, angle, …]) Rotate lattice around hkl direction by angle or to align to vector.
rhombicLattice.vectorhkl(hkl) Get vector corresponding to hkl direction.

Lattice objects describing a lattice of points.

Included are methods to select sublattices as parallelepiped, sphere or side of planes.

The small angle scattering is calculated by js.ff.cloudScattering.

The same method can be used to calculate the wide angle scattering with bragg peaks using larger scattering vectors to get crystalline bragg peaks of nanoparticles.

Examples

A hollow sphere cut to a wedge.

import jscatter as js
import numpy as np
grid= js.lattice.scLattice(1/2.,2*8,b=[0])
grid.inSphere(6,b=1)
grid.inSphere(4,b=0)
grid.planeSide([1,1,1],b=0)
grid.planeSide([1,-1,-1],b=0)
grid.show()

q=js.loglist(0.01,5,600)
ffe=js.ff.cloudScattering(q,grid.points,relError=0.02,rms=0.1)
p=js.grace()
p.plot(ffe)

A cube decorated with spheres.

import jscatter as js
import numpy as np
grid= js.lattice.scLattice(0.2,2*15,b=[0])
v1=np.r_[4,0,0]
v2=np.r_[0,4,0]
v3=np.r_[0,0,4]
grid.inParallelepiped(v1,v2,v3,b=1)
grid.inSphere(1,center=[0,0,0],b=2)
grid.inSphere(1,center=v1,b=3)
grid.inSphere(1,center=v2,b=4)
grid.inSphere(1,center=v3,b=5)
grid.inSphere(1,center=v1+v2,b=6)
grid.inSphere(1,center=v2+v3,b=7)
grid.inSphere(1,center=v3+v1,b=8)
grid.inSphere(1,center=v3+v2+v1,b=9)
grid.show()

q=js.loglist(0.01,5,600)
ffe=js.ff.cloudScattering(q,grid.points,relError=0.02,rms=0.)
p=js.grace()
p.plot(ffe)

A comparison of sc, bcc and fcc nanoparticles (takes a while )

import jscatter as js
import numpy as np
q=js.loglist(0.01,35,1500)
q=np.r_[js.loglist(0.01,3,200),3:40:800j]
unitcelllength=1.5
N=8

scgrid= js.lattice.scLattice(unitcelllength,N)
sc=js.ff.cloudScattering(q,scgrid.points,relError=50,rms=0.05)
bccgrid= js.lattice.bccLattice(unitcelllength,N)
bcc=js.ff.cloudScattering(q,bccgrid.points,relError=50,rms=0.05)
fccgrid= js.lattice.fccLattice(unitcelllength,N)
fcc=js.ff.cloudScattering(q,fccgrid.points,relError=50,rms=0.05)

p=js.grace(1.5,1)
# smooth with Gaussian to include instrument resolution
p.plot(sc.X,js.formel.smooth(sc,10, window='gaussian'),legend='sc')
p.plot(bcc.X,js.formel.smooth(bcc,10, window='gaussian'),legend='bcc')
p.plot(fcc.X,js.formel.smooth(fcc,10, window='gaussian'),legend='fcc')

q=q=js.loglist(1,35,100)
p.plot(q,(1-np.exp(-q*q*0.05**2))/scgrid.shape[0],li=1,sy=0,le='sc diffusive')
p.plot(q,(1-np.exp(-q*q*0.05**2))/bccgrid.shape[0],li=2,sy=0,le='bcc diffusive')
p.plot(q,(1-np.exp(-q*q*0.05**2))/fccgrid.shape[0],li=3,sy=0,le='fcc diffusive')

p.title('Comparison sc, bcc, fcc lattice for a nano cube')
p.yaxis(scale='l',label='I(Q)')
p.xaxis(scale='l',label='Q / A\S-1')
p.legend(x=0.03,y=0.001,charsize=1.5)
p.text('cube formfactor',x=0.02,y=0.05,charsize=1.4)
p.text('Bragg peaks',x=4,y=0.05,charsize=1.4)
p.text('diffusive scattering',x=4,y=1e-6,charsize=1.4)

Structure factors and directly related functions for scattering related to interaction potentials between particles.

Return values are dataArrays were useful.

To get only Y values use .Y

For RMSA an improved algorithm is used based on the original idea (see Notes in RMSA).

jscatter.structurefactor.PercusYevick(q, R, molarity=None, eta=None)[source]

The Percus-Yevick structure factor.

Structure factor for the potential U(r)= (inf for 0<r<R) and (0 for R<r).

Parameters:
q : array; N dim

scattering vector; units 1/(R[unit])

R : float

Radius of the object

eta : float

volume fraction as eta=4/3*pi*R**3*n with number density n in units or R

molarity : float

number density in mol/l and defines q and R units to 1/nm and nm to be correct preferred over eta if both given

Returns:
dataArray

structure factor for given q

Notes

Problem is given in [1]; solution in [2] and best description of the solution is in [3].

References

[1](1, 2)
    1. Percus and G. J. Yevick, Phys. Rev. 110, 1 (1958).
[2](1, 2)
    1. Wertheim, Phys. Rev. Lett. 10, 321 (1963).
[3](1, 2)
    1. Kinning and E. L. Thomas, Macromolecules 17, 1712 (1984).
jscatter.structurefactor.PercusYevick1D(q, R=1, eta=0.1)[source]

The PercusYevick structure factor in 1D

Structure factor for the potential U(r)= (inf for 0<r<R) and (0 for R<r).

Parameters:
q : array; N dim

scattering vector; units 1/(R[unit])

R : float

Radius of the object

eta : float

packing fraction as eta=2*R*n with number density n

Returns:
dataArray
[q,structure factor]

Notes

[1]Exact solution of the Percus-Yevick equation for a hard-core fluid in odd dimensions Leutheusser E Physica A 1984 vol: 127 (3) pp: 667-676
[2]On the equivalence of the Ornstein–Zernike relation and Baxter’s relations for a one-dimensional simple fluid Chen M Journal of Mathematical Physics 1975 vol: 16 (5) pp: 1150
jscatter.structurefactor.PercusYevick2D(q, R=1, eta=0.1, a=None)[source]

The PercusYevick structure factor in 2D

Structure factor for the potential U(r)= (inf for 0<r<R) and (0 for R<r).

Parameters:
q : array; N dim

scattering vector; units 1/(R[unit])

R : float, default 1

Radius of the object

eta : float, default 0.1

packing fraction as eta=pi*R**2*n with number density n maximum hexagonal closed = (np.pi*R**2)/(3/2.*3**0.5*a**2) Rmax=a*3**0.5/2. with max packing of 0.9069

a : float, default None

hexagonal lattice constant if not None the packing fraction in hexagonal lattice as eta=(np.pi*R**2)/(3/2.*3**0.5*a**2) is used

Returns:
dataArray

References

[1]Free-energy model for the inhomogeneous hard-sphere fluid in D dimensions: Structure factors for the hard-disk (D=2) mixtures in simple explicit form Yaakov Rosenfeld Phys. Rev. A 42, 5978
jscatter.structurefactor.RMSA(q, R, scl, gamma, molarity=None, eta=None, useHP=False)[source]

Structure factor for a screened coulomb interaction in rescaled mean spherical approximation (RMSA).

Structure factor according to Hayter-Penfold [1] [2] . Consider a scattering system consisting of macro ions, counter ions and solvent. Here an improved algorithm is used based on the original idea described in [1] (see Notes).

Parameters:
q : array; N dim

Scattering vector; units 1/nm

R : float

Radius of the object; units nm

molarity : float

Number density n in units mol/l. Overrides eta, if both given.

scl : float>0

Screening length; units nm; negative values evaluate to scl=0.

gamma : float
contact potential; units kT
gamma=Zm/(pi*e0*e*R*(2+k*R))
Zm = Z* effective surface charge
e0,e free permittivity and dielectric constant
k=1/scl inverse screening length of Debye-Hückel potential
eta : float

Volume fraction as eta=4/3*pi*R**3*n with number density n.

useHP : True, default False

To use the original Hayter/Penfold algorithm. This gives wrong results for some parameter conditions. It should ONLY be used for testing. See example examples/test_newRMSAAlgorithm.py for a direct comparison.

Returns:
dataArray : .
  • .volumeFraction = eta
  • .rescaledVolumeFraction
  • .screeningLength
  • .gamma=gamma
  • .contactpotential
  • .S0 structure factor at q=0
  • .scalingfactor factor for rescaling to get g+1=0; if =1 nothing was scaled and it is MSA

Notes

Improved algorithm
The Python code is deduced from the original Hayter-Penfold Fortran code (1981, ILL Grenoble). This is also used in other common SAS programs as SASfit or SASview (translated to C). The original algorithm determines the root of a quartic F(w1,w2,w3,w4) by an estimate (named PW estimate), refining it by a Newton algorithm. As the PW estimate is sometimes not good enough this results in an arbitrary root of the quartic in the Newton algorithm. The solution therefore jumps between different possibilities by small changes of the parameters. We use here the original idea from [1] to calculate G(r<0) for all four roots of F(w1,w2,w3,w4) and use the physical solution with G(r<R)=0. See examples/test_newRMSAAlgorithm.py for a direct comparison.
Validity
The calculation of charge at the surface or screening length from a solute ion concentration is explicitly dedicate to the user. The Debye-Hückel theory for a macro ion in screened solution is a far field theory as a linearization of the Poisson-Boltzmann (PB) theory and from limited validity (far field or low charge -> linearization). Things like reverting charge layer, ion condensation at the surface, pH changes at the surface or other things might appear. Before calculating please take these things into account. Close to the surface the PB has to be solved. The DH theory can still be used if the charge is thus an effective charge named Z*, which might be different from the real surface charge. See Ref [3] for details.

References

[1](1, 2, 3, 4)
    1. Hayter and J. Penfold, Mol. Phys. 42, 109 (1981).
[2](1, 2) J.-P. Hansen and J. B. Hayter, Mol. Phys. 46, 651 (2006).
[3](1, 2)
  1. Belloni, J. Phys. Condens. Matter 12, R549 (2000).
jscatter.structurefactor.adhesiveHardSphere(q, R, tau, delta, molarity=None, eta=None)[source]

structure factor of a adhesive hard sphere potential (a square well potential)

Parameters:
q : array; N dim

scattering vector; units 1/(R[unit])

R : float

radius of the hard core

eta : float

volume fraction of the hard core particles

molarity : float

number density in mol/l and defines q and R units to 1/nm and nm to be correct preferred over eta if both given

tau : float

stickiness

delta : float

width of the square well

Notes

The potential U(r) is defined as r<2R U(r)=infinity 2R<r<2R+delta U(r)=-depth=ln(12*tau*delta/(2R+delta)) r >2R+delta U(r)=0

References

[1]
  1. Regnaut and J. C. Ravey, J. Chem. Phys. 91, 1211 (1989).
[2]
  1. Regnaut and J. C. Ravey, J. Chem. Phys. 92 (5) (1990), 3250 Erratum
jscatter.structurefactor.criticalSystem(q, corrlength, isothermalcompress)[source]

Structure factor of a critical system should take the Ornstein-Zernike form.

Parameters:
q : array; N dim

scattering vector; units 1/(R[unit])

corrlength : float

correlation length

isothermalcompress : float

isothermal compressibility of the system

Notes

The peaking of the structure factor near Q=0 region is due to attractive interaction. Away from it the structure factor should be close to the hard sphere structure factor. Near the critical point we should find S(Q)=S_PY(Q)+S_OZ(Q) S_PY Percus Yevick structure factor S_OZ this function

References

[1]Analysis of Critical Scattering Data from AOT/D2O/n-Decane Microemulsions S. H. Chen, T. L. Lin, M. Kotlarchyk Surfactants in Solution pp 1315-1330
jscatter.structurefactor.hydrodynamicFunct(wavevector, Rh, molarity, intrinsicVisc=None, DsoverD0=None, structureFactor=None, structureFactorArgs={}, numberOfPoints=50, ncpu=-1)[source]

Hydrodynamic function H(q) from hydrodynamic pair interaction of spheres in suspension.

This allows the correction D_T(q)=D_{T0}H(q)/S(q) for the translational diffusion D_T(q) coefficient at finite concentration. We use the theory from Beenakker and Mazur [2] as given by Genz [1]. The \delta\gamma-expansion of Beenakker expresses many body hydrodynamic interaction within the renormalization approach dependent on the structure factor S(q).

Parameters:
wavevector : array

scattering vector q in units 1/nm

Rh : float

effective hydrodynamic radius of particles in nm.

molarity : float
molarity in mol/l
This overrides a parameter ‘molarity’ in the structureFactorArgs.
Rh and molarity define the hydrodynamic interaction, the volume fraction and Ds/D0 for H(Q).
The structure factor may have a radius different from Rh e.g. for attenuated hydrodynamic interactions.
DsoverD0 : float
The high Q limit of the hydrodynamic function is for low volume fractions
Ds/D0= 1/(1+intrinsicVisc * volumeFraction ) with self diffusion Ds.
Ds is calculated from molarity and Rh.
This explicit value overrides intrinsic viscosity and calculated Ds/D0.
structureFactor : function, None
Structure factor S(q) with S(q=inf)=1.0 recommended.
1: If structurefactor is None a Percus-Yevick is assumed with molarity and R=Rh.
2: A function S(q,…) is given as structure factor, which might be an
empirical function (e.g. polynominal fit of a measurement)
First parameter needs to be wavevector q .
If “molarity” parameter is present it is overwritten by molarity above.
structureFactorArgs : dictionary

Any extra arguments to structureFactor e.g. structFactorArgs={‘x’:0.123,R=3,….}

intrinsicVisc : float
Defines the high q limit for the hydrodynamic function.
effective_viscosity= eta_solvent * (1-intrinsicVisc*Volumefraction )
intrinsicVisc = 2.5 Einstein hard sphere density 1 g/cm**3
For proteins instead of volume fraction the protein concentration in g/ml with typical
protein density 1.37 g/cm^3 is often used.
Intrinsic Viscosity depends on protein shape (see HYDROPRO).
Typical real values for intrinsicVisc in practical units cm^3/g
sphere 1.76 cm^3/g= 2.5 sphere with protein density
ADH 3.9 = 5.5 a tetrameric protein
PGK 4.0 = 5.68 two domains with hinge-> elongated
Rnase 3.2 = 4.54 one domain
eta_solvent/effective_viscosity = (1-intrinsicVisc * Volumefraction )=Dself/D0
numberOfPoints : integer, default 50

Determines number of integration points in equ 5 of ref [1] and therefore accuracy of integration. The typical accuracy of this function is <1e-4 for (H(q) -highQLimit) and <1e-3 for Ds/D0.

Returns:
dataArray
[0] q values
[1] hydrodynamic function
[2] hydrodynamic function only Q dependent part = H(q) -highQLimit
[3] structure factor for H(q) calculation
.selfdiffusion Ds

Notes

Ds is calculated according to equ 11 in [1] which is valid for volume fractions up to 0.5. With this assumption the deviation of self diffusion Ds from Ds=Do*[1-1.73*phi+0.88*phi**2+ O(phi**3)] is smaller 5% for phi<0.2 (10% for phi<0.3)

References

[1](1, 2, 3, 4)
  1. Genz and R. Klein, Phys. A Stat. Mech. Its Appl. 171, 26 (1991).
[2](1, 2)
      1. Beenakker and P. Mazur, Phys. A Stat. Mech. Its Appl. 126, 349 (1984).
[3]
      1. Beenakker and P. Mazur, Phys. A Stat. Mech. Its Appl. 120, 388 (1983).
jscatter.structurefactor.latticeStructureFactor(q, lattice=None, domainsize=1000, asym=0, lg=1, rmsd=0.02, beta=None, hklmax=7, c=1.0)[source]

Radial structure factor S(q) in powder average of a crystal lattice with particle asymmetry, DebyeWaller factor, diffusive scattering and broadening due to domain size.

The peak shape is a Voigt function. To get the full scattering the formfactor needs to be included (See Notes and Examples). 1-3 dimensional lattice structures with basis containing multiple atoms (see lattice).

Parameters:
q : float

Wavevector in inverse units of lattice constant, units 1/A or 1/nm

domainsize : float

Domainsize of the crystal, units as lattice constant of lattice. According to Debye-Scherrer equation fwhm=2\pi/domainsize the peak width is determined [2].

lattice : lattice object

The crystal structure as defined in a lattice object. The size of the lattice is ignored. One of rhombicLattice, bravaisLattice, scLattice, bccLattice, fccLattice, diamondLattice, hexLattice, hcpLattice. See respective definitions.

lg : float, default = 1
Lorenzian/gaussian fraction describes the contributions of gaussian and lorenzian shape in peak shape.
  • lorenzian/gaussian >> 1 lorenzian,
  • lorenzian/gaussian ~ 1 central part gaussian, outside lorenzian wings
  • lorenzian/gaussian << 1 gaussian
asym : float, default=0

Asymmetry factor in sigmoidal as 2fwhm/(1+e^{asym*(x-center)}) For asym=0 the Voigt is symmetric with fwhm. See formel.voigt .

rmsd : float, default=0.02

Root mean square displacement rmsd=<u^2>^{0.5} determining the Debye Waller factor. Units as domainsize and lattice units. Here Debye Waller factor is used as DW(q)=e^{-q^2 rmsd^2 }

beta : float, None, dataArray
Asymmetry factor of the formfactor or reduction due to polydispersity.
  • None beta=1, No beta assumed (spherical symmetric formfactor, no polydispersity)
  • dataArray explicitly given as dataArray with beta in .Y column. Missing values are interpolated.
  • An approximation for polydisperse beta can be found in [1] equ.17. This can be realized by beta=js.dA(np.vstack(q,np.exp(-(q*sr*R)**2))) with sr as relative standard deviation of gaussian distribution of the size R.
  • See .formfactor for different formfactors which explicit calculation of beta.
hklmax : int

Maximum order of the Bragg peaks to include.

c : float, default=1

Porod constant. See 3.8 in [1].

Returns:
dataArray with columns [q,Sq,DW,beta,Z0q]
  • q wavevector
  • Sq = S(q) = 1+beta(q)*(Z0(q)-1)*DW(q) structure factor
  • DW(q) Debye-Waller factor with (1-DW)=diffusive scattering.
  • beta(q) asymmetry factor of the formfactor.
  • Z0q lattice factor Z0(q)
Attributes
  • .q_hkl peak positions
  • .fhkl symmetry factor
  • .mhkl multiplicity

Notes

  • The scattering intensity of a crystal domain in powder average is

    I(q)={\Delta\rho}^2 n P(q) S(q)

    with
    • \Delta\rho scattering length difference between matrix and particles
    • n number density (of elementary cells)
    • P(q) form factor
    • S(q) structure factor S(q)

    For inhomogeneous particles we can incorporate \Delta\rho(r) in the formfactor P(q) if this includes the integrated scattering length differences.

  • The structure factor is [1] :

    S(q)=1+ \beta(q)(Z_0(q)-1)*DW(Q)

    with
    • \beta(q)=<F(q)>^2/<F(q)^2> as asymmetry factor [3] dependent on the scattering amplitude F(q) and particle polydispersity
    • DW(q) Debye Waller factor
  • The lattice factor is [1] :

    Z_0(q) = \frac{(2\pi)^{d-1}c}{nv_dq^{d-1}} \sum\limits_{hkl}m_{hkl}f_{hkl}^2L_{hkl}(q)

    with
    • n number of particles per unit cell
    • f_{hkl} unit cell structure factor that takes into account symmetry-related extinction rules
    • v_d volume of the d-dimensional unit cell
    • hkl reflections
    • m_{hkl} peak multiplicity
    • c Porod constant \simeq 1
  • We use a Voigt function for the peak shape L_{hkl}(q) (see formel.voigt).

  • DW is a Debye Waller like factor as DW(q)=e^{-q^2<u^2>} leading to a reduction of scattered intensity and diffusive scattering. It has contributions from thermal lattice disorder ( DW factor with 1/3 factor in 3D), surface roughness and size polydispersity.

  • For the limiting behaviour q->0 see the discussion in [1] in 3.9. :

    “… The zero-order peak is not explicitly considered because of the q^(1-dim) singularity and because its intensity depends also on the scattering length difference between the lattice inside and outside…… Due to the singularity and since structural features on length scales d > a, such as packing defects, grain boundaries or fluctuations decaying on larger length scales are only indirectly considered via the domain size D, eq 30 is not expected to give good agreement with experimentally determined scattering curves in the range of scattering vectors q < 2π/a. However, for q > 2π/a, this approach describes remarkably well experimentally measured high-resolution scattering curves….”

    A good description of the real scattering for low Q is shown in example A nano cube build of different lattices.

References

[1](1, 2, 3, 4, 5, 6) Scattering curves of ordered mesoscopic materials. Förster, S. et al. J. Phys. Chem. B 109, 1347–1360 (2005).
[2](1, 2) Patterson, A. The Scherrer Formula for X-Ray Particle Size Determination Phys. Rev. 56 (10): 978–982 (1939) doi:10.1103/PhysRev.56.978.
[3](1, 2)
  1. Kotlarchyk and S.-H. Chen, J. Chem. Phys. 79, 2461 (1983).1

Examples

import jscatter as js
import numpy as np
q = np.r_[0.001:1:800j]
a = 50.
R=15
sr=0.1
p = js.grace()
beta=js.dA(np.vstack([q,np.exp(-(q*sr*R)**2)]))
p.title('structure factor for hexagonal 2D lattice')
p.subtitle('with diffusive scattering and asymmetry factor beta')
for i,rmsd in enumerate([1., 3., 10., 30.],1):
    grid=js.sf.hexLattice(50,5)
    hex = js.sf.latticeStructureFactor(q, rmsd=rmsd, domainsize=500., beta=beta,lattice=grid)
    p.plot(hex, li=[1, 2, i], sy=0, le='rmsd=$rmsd')
    p.plot(hex.X,1-hex[-3], li=[3, 2, i], sy=0)
p.plot(hex.X, hex[-2], li=[2, 2, i], sy=0, le='beta')
p.text(r'broken lines \nshow diffusive scattering',x=0.4,y=6)
p.yaxis(label='S(q)')
p.xaxis(label='q / nm')
p.legend(x=0.6,y=4)

import jscatter as js
import numpy as np
q=np.r_[js.loglist(0.1,3,200),3:40:800j]
unitcelllength=1.5
N=2
R=0.5
sr=0.1
beta=js.dA(np.vstack([q,np.exp(-(q*sr*R)**2)]))
rmsd=0.02
#
scgrid= js.lattice.scLattice(unitcelllength,N)
sc=js.sf.latticeStructureFactor(q, rmsd=rmsd, domainsize=50., beta=beta,lattice=scgrid)
bccgrid= js.lattice.bccLattice(unitcelllength,N)
bcc=js.sf.latticeStructureFactor(q, rmsd=rmsd, domainsize=50., beta=beta,lattice=bccgrid)
fccgrid= js.lattice.fccLattice(unitcelllength,N)
fcc=js.sf.latticeStructureFactor(q, rmsd=rmsd, domainsize=50., beta=beta,lattice=fccgrid)
#
p=js.grace()
p.plot(sc,legend='sc')
p.plot(bcc,legend='bcc')
p.plot(fcc,legend='fcc')
p.text(r'broken lines \nshow diffusive scattering',x=10,y=0.1)
p.yaxis(label='S(q)',scale='l',max=50,min=0.05)
p.xaxis(label='q / nm',scale='l',max=50,min=0.5)
p.legend(x=1,y=30,charsize=1.5)
jscatter.structurefactor.orientedLatticeStructureFactor(qxyz, lattice, rotation=None, domainsize=1000, rmsd=0.02, beta=None, hklmax=3, nGauss=13)[source]

2D structure factor S(q) of an oriented crystal lattice including particle asymmetry, DebyeWaller factor, diffusive scattering, domain rotation and domain size.

To get the full scattering the formfactor needs to be included (See Notes and Examples). 1-3 dimensional lattice structures with basis containing multiple atoms (see lattice). To orient the crystal lattice use lattice methods .rotatehkl2Vector and .rotateAroundhkl

Parameters:
qxyz : array 3xN

Wavevector array representing a slice/surface in q-space (3D), units 1/A or 1/nm. This can describe a detector plane, section of the Ewald sphere or a line in reciprocal space.

lattice : lattice object

Lattice object with arbitrary atoms particles in unit cell, or predefined lattice from rhombicLattice, bravaisLattice, scLattice,bccLattice, fccLattice, diamondLattice, hexLattice, hcpLattice with scattering length of unit cell atoms. See lattices for examples.

rotation : 4x float as [h,k,l,sigma], None

Average over rotation of the crystal around axis hkl with Gaussian distribution of width sigma (units rad) around actual orientation.

domainsize : float,list, list of directions

Domainsize of the crystal, units as lattice constant of lattice. According to Debye-Scherrer equation fwhm=2\pi/domainsize the peak width is determined [2].

  • float : assume same domainsize in all directions.
  • list 3 float : domainsize in directions of latticeVectors.
  • list 4 x 3 : 3 times domainsize in hkl direction as [[size,h,k,l] ,[..],[..] ]
    [[3,1,1,1],[100,1,-1,0],[100,1,1,-2]] is thin in 111 direction and others are thick The user should take care that the directions are nearly orthogonal.
rmsd : float, default=0.02

Root mean square displacement <u^2>^{0.5} determining the Debye Waller factor. Units as lattice constant.

beta : float, None, dataArray
Asymmetry factor of the formfactor or reduction due to polydispersity.
  • None beta=1, No beta assumed (spherical symmetric formfactor, no polydispersity)
  • dataArray beta explicitly given as dataArray with beta in .Y column. Missing values are interpolated.
  • An approximation for polydisperse beta can be found in [1] equ.17. This can be realized by beta=js.dA(np.vstack(q,np.exp(-(q*sr*R)**2))) with sr as relative standard deviation of gaussian distribution of the size R.
  • See .formfactor for different formfactors which explicit calculation of beta.
hklmax : int

Maximum order of the Bragg peaks.

nGauss : int, default 13

Number of points in integration over Gaussian for rotation width sigma.

Returns:
dataArray with columns [qx,qy,qz,Sq,DW,beta,Z0q]
  • q wavevector
  • Sq = S(q) = 1+beta(q)*(Z0(q)-1)*DW(q) structure factor
  • DW(q) Debye-Waller factor with (1-DW)=diffusive scattering.
  • beta(q) asymmetry factor of the formfactor.
  • Z0q lattice factor Z0(q)
Attributes (+ input parameters)
  • .q_hkl peak positions
  • .hkl Miller indices
  • .peakFWHM full width half maximum

Notes

  • The scattering intensity of a crystal domain is

    I(q)={\Delta\rho}^2 n P(q) S(q)

    with
    • \Delta\rho scattering length difference between matrix and particles
    • n number density (of elementary cells)
    • P(q) form factor
    • S(q) structure factor S(q)

    For inhomogeneous particles we can incorporate \Delta\rho(r) in the formfactor P(q) if this includes the integrated scattering length differences.

  • The structure factor is [1] :

    S(q)=1+ \beta(q)(Z_0(q)-1)*DW(Q)

    with
    • \beta(q)=<F(q)>^2/<F(q)^2> as asymmetry factor [3] dependent on the scattering amplitude F(q) and particle polydispersity
    • DW(q) Debye Waller factor
  • The lattice factor is [1] :

    Z_0(q) = \frac{(2\pi)^3}{mv} \sum\limits_{hkl}f_{hkl}^2L_{hkl}(q,g_{hkl})

    with
    • g_{hkl} peak positions
    • m number of particles per unit cell
    • f_{hkl} unit cell structure factor that takes into account symmetry-related extinction rules
    • v volume of the unit cell
    • hkl reflections
  • The peak shape function is

    L_{hkl}(q,g_{hkl}) = \frac{1}{ \sqrt{2\pi} \sigma} e^{-\frac{(q-g_{hkl})^2}{2\sigma^2}}

    with \sigma=fwhm/2\sqrt{2log(2)} related to the domainsize.

    Correspondingly \sigma is a vector describing the peak shapes in all directions.

  • Distributions of domain orientation are included by the parameter rotation that describes gaussian distributions with mean and sigma around an axis defined by the corresponding hkl indices.

  • DW is a Debye Waller like factor as DW(q)=e^{-q^2<u^2>} leading to a reduction of scattered intensity and diffusive scattering. It has contributions from thermal lattice disorder ( DW factor with 1/3 factor in 3D).

  • To get the scattering of a specific particle shape the formfactor has to be included. The above is valid for isotropic scatterers (symmetric or uncorrelated to the crystal orientation) as only in this case we can separate structure factor and form factor.

References

[1](1, 2, 3, 4) Order causes secondary Bragg peaks in soft materials Förster et al Nature Materials doi: 10.1038/nmat1995
[2](1, 2) Patterson, A. The Scherrer Formula for X-Ray Particle Size Determination Phys. Rev. 56 (10): 978–982 (1939) doi:10.1103/PhysRev.56.978.
[3](1, 2)
  1. Kotlarchyk and S.-H. Chen, J. Chem. Phys. 79, 2461 (1983).1

Examples

Comparison fcc and sc to demonstrate selection rules

import jscatter as js
import numpy as np
R=8
N=50
ds=10
fcclattice= js.lattice.fccLattice(3.1, 5)
qxy=np.mgrid[-R:R:N*1j, -R:R:N*1j].reshape(2,-1).T
qxyz=np.c_[qxy,np.zeros(qxy.shape[0])]
fcclattice.rotatehkl2Vector([1,1,1],[0,0,1])
ffe=js.sf.orientedLatticeStructureFactor(qxyz,fcclattice,domainsize=ds,rmsd=0.1,hklmax=4)
fig=js.mpl.surface(ffe.X,ffe.Z,ffe.Y)
sclattice= js.lattice.scLattice(3.1, 5)
sclattice.rotatehkl2Vector([1,1,1],[0,0,1])
ffs=js.sf.orientedLatticeStructureFactor(qxyz,sclattice,domainsize=ds,rmsd=0.1,hklmax=4)
fig=js.mpl.surface(ffs.X,ffs.Z,ffs.Y)

Comparison of different domainsizes dependent on direction of scattering

import jscatter as js
import numpy as np
R=8
N=50
qxy=np.mgrid[-R:R:N*1j, -R:R:N*1j].reshape(2,-1).T
qxyz=np.c_[qxy,np.zeros(qxy.shape[0])]
sclattice= js.lattice.scLattice(2.1, 5)
sclattice.rotatehkl2Vector([1,0,0],[0,0,1])
ds=[[20,1,0,0],[5,0,1,0],[5,0,0,1]]
ffs=js.sf.orientedLatticeStructureFactor(qxyz,sclattice,domainsize=ds,rmsd=0.1,hklmax=2)
fig=js.mpl.surface(ffs.X,ffs.Z,ffs.Y)
fig.axes[0].set_title('symmetric peaks: thinner direction perpendicular to scattering plane')
fig.show()
sclattice= js.lattice.scLattice(2.1, 5)
sclattice.rotatehkl2Vector([0,1,0],[0,0,1])
ffs=js.sf.orientedLatticeStructureFactor(qxyz,sclattice,domainsize=ds,rmsd=0.1,hklmax=2)
fig2=js.mpl.surface(ffs.X,ffs.Z,ffs.Y)
fig2.axes[0].set_title('asymmetric peaks: thin direction is parallel to scattering plane')
fig2.show()

Rotation along [1,1,1] axis. It looks spiky because of low number of points in xy plane. To improve this the user can use more points, which needs longer computing time

import jscatter as js
import numpy as np
# make xy grid in q space
R=8    # maximum
N=800  # number of points
ds=15;
qxy=np.mgrid[-R:R:N*1j, -R:R:N*1j].reshape(2,-1).T
# add z=0 component
qxyz=np.c_[qxy,np.zeros(qxy.shape[0])] # as position vectors
# create sc lattice which includes reciprocal lattice vectors and methods to get peak positions
sclattice= js.lattice.scLattice(2.1, 5)
# Orient 111 direction perpendicular to qxy plane
sclattice.rotatehkl2Vector([1,1,1],[0,0,1])
# rotation by 15 degrees to be aligned to xy plane
sclattice.rotateAroundhkl([1,1,1],np.deg2rad(15))
ffs=js.sf.orientedLatticeStructureFactor(qxyz,sclattice, rotation=[1,1,1,np.deg2rad(10)],
                                        domainsize=ds,rmsd=0.1,hklmax=2,nGauss=23)
fig=js.mpl.surface(ffs.X,ffs.Z,ffs.Y)
jscatter.structurefactor.radialorientedLSF(*args, **kwargs)[source]

Radial averaged structure factor S(q) of an oriented crystal lattice calculated as orientedLatticeStructureFactor.

For a detailed description and parameters see orientedLatticeStructureFactor. Additionally the qxyz plane according to orientedLatticeStructureFactor is radial averaged over qxyz.

Parameters:
number : int

Number of intervals between min and max wavevector values To large number results in noisy data as the average gets artificial.

Returns:
dataArray with columns [q,Sq,DW,beta,Z0q]
  • q wavevector as norm(qx,qy,qz)
  • Sq = S(q) = 1+beta(q)*(Z0(q)-1)*DW(q) structure factor
  • DW(q) Debye-Waller factor with (1-DW)=diffusive scattering.
  • beta(q) asymmetry factor of the formfactor.
  • Z0q lattice factor Z0(q)
Attributes (+ input parameters)
  • .q_hkl peak positions
  • .hkl Miller indices
  • .peakFWHM full width half maximum

Notes

qxyz might be any number and geometrical distribution as plane or 3D cube. 3D qxyz points will be converted to qr=norm(qxyz) and averaged.

Examples

import jscatter as js
import numpy as np

R=12
N=200
ds=10
fcclattice= js.lattice.fccLattice(3.1, 5)
qxy=np.mgrid[-R:R:N*1j, -R:R:N*1j].reshape(2,-1).T
qxyz=np.c_[qxy,np.zeros(N**2)]
ffe=js.sf.radialorientedLSF(qxyz=qxyz,lattice=fcclattice,orientation=[1,1,1],domainsize=ds,rmsd=0.07,hklmax=6)
p=js.grace()
p.plot(ffe)
jscatter.structurefactor.sq2gr(Sq, R, interpolatefactor=2)[source]

Radial distribution function g(r) from structure factor Sq.

The result strongly depends on quality of S(Q) (number of data points, Q range, smoothness). Read [2] for details of this inversion problem and why it may fail.

Parameters:
Sq : dataArray
Structure factor e.g. in units as [Q]=1/nm
  • .X wavevector
  • .Y structure factor
R : float

Estimate for the radius of the particles.

interpolatefactor : int

Number of points between points in interpolation for rfft. 2 doubles the points

Returns:
dataArray

.n0 approximated from 2\pi^2 n_0=\int_0^{Q_{max}} [S(Q) -1]Q^2 dQ

Notes

One finds that

g(r)-1=(2\pi^2 n_0 r)^{-1} \int_0^\infty [S(Q) -1]Qsin(qr)dQ

with 2\pi^2 n_0=\int_0^\infty [S(Q) -1]Q^2 dQ defining n_0.

As we have only a limited Q range (0 < Q < \infty ), limited accuracy and number of Q values we require that mean(g(R/2<r<R3/4))=0.

References

[1]Yarnell, J. L., Katz, M. J., Wenzel, R. G., & Koenig, S. H. (1973). Structure factor and radial distribution function for liquid argon at 85 K. Physical Review A, 7(6), 2130.
[2](1, 2) On the determination of the pair correlation function from liquid structure factor measurements A.K. Soper Chemical Physics 107, 61-74, (1986)

Examples

import jscatter as js
import numpy as np
p=js.grace()
p.multi(2,1)
q=js.loglist(0.01,100,2**13)
p[0].clear();p[1].clear()
R=2.5
eta=0.3;scl=5
n=eta/(4/3.*np.pi*R**3)   # unit 1/nm**3
sf=js.sf.RMSA(q=q,R=R,scl=scl, gamma=50, eta=eta)
gr=js.sf.sq2gr(sf,R,interpolatefactor=1)
sfcut=js.sf.RMSA(js.loglist(0.01,10,2**10),R=R,scl=scl, gamma=50, eta=eta)
grcut=js.sf.sq2gr(sfcut,R,interpolatefactor=5)
p[0].plot(sf.X*2*R,sf.Y,le=r'\xG=50')
p[1].plot(gr.X/2/R,gr[1],le=r'\xG=50')
p[1].plot(grcut.X/2/R,grcut[1],le=r'\xG=50 \f{}Q\smax\N=10')
sfh=js.sf.RMSA(q=q,R=R,scl=scl, gamma=0.01, eta=eta)
grh=js.sf.sq2gr(sfh,R,interpolatefactor=1)
p[0].plot(sfh.X*2*R,sfh.Y,le=r'\xG=0.01')
p[1].plot(grh.X/2/R,grh[1],le=r'\xG=0.01')
p[0].xaxis(max=20,label='2RQ')
p[1].xaxis(max=4*R,label='r/(2R)')
p[0].yaxis(max=2,min=0,label='S(Q)')
p[1].yaxis(max=2.5,min=0,label='g(r)')
p[0].legend(x=10,y=1.8)
p[1].legend(x=4,y=1.8)
p[0].title('Comparison RMSA')
p[0].subtitle('R=%.2g, eta=%.2g, scl=%.2g' %(R,eta,scl))
jscatter.structurefactor.stickyHardSphere(q, R, width, depth, molarity=None, phi=None)[source]

Structure factor of a square well potential with depth and width (sticky hard spheres).

Sticky hard sphere model is derived using a perturbative solution of the factorized form of the Ornstein-Zernike equation and the Percus-Yevick closure relation. The perturbation parameter is width/(width+2R)

Parameters:
q : array; N dim

Scattering vector; units 1/(R[unit])

R : float

Radius of the hard sphere

phi : float

Volume fraction of the hard core particles

molarity : float

Number density in mol/l and defines q and R units to 1/nm and nm to be correct Preferred over phi if both given.

depth : float

Potential well depth in kT depth >0 (U<0); positive potential allowed (repulsive) see [1].

width : float

Width of the square well

Notes

The potential U(r) is defined as
r<2R U(r)=infinity
2R<r<2R+width U(r)=-depth in [kT]
r >2R+width U(r)=0

eps=width/(2*R+width) stickiness=exp(-depth)/12./eps

References

[1](1, 2) S.V. G. Menon, C. Manohar, and K. S. Rao, J. Chem. Phys. 95, 9186 (1991)
[2]
  1. Sztucki, T. Narayanan, G. Belina, A. Moussaïd, F. Pignon, and H. Hoekstra, Phys. Rev. E 74, 051504 (2006)
[3]W.-R. Chen, S.-H. Chen, and F. Mallamace, Phys. Rev. E 66, 021403 (2002)
[4]
  1. Foffi, E. Zaccarelli, F. Sciortino, P. Tartaglia, and K. A. Dawson, J. Stat. Phys. 100, 363 (2000)
class jscatter.structurefactor.lattice[source]

Create an arbitrary lattice.

Please use one of the subclasses below for creation.

pseudorandom, rhombicLattice, bravaisLattice scLattice, bccLattice, fccLattice, diamondLattice, hexLattice, hcpLattice, sqLattice, hexLattice, lamLattice

This base class defines methods valid for all subclasses.

X

X coordinates

XYZ

X,Y,Z coordinates array Nx3

Y

Y coordinates

Z

Z coordinates

array

Coordinates and scattering length as array

b

Scattering length

centerOfMass()[source]

Center of mass as center of geometry.

filter(funktion)[source]

Set lattice points scattering length according to a function.

All points in the lattice are changed for which funktion returns value !=0 (tolerance 1e-12).

Parameters:
funktion : function returning float

Function to set lattice points scattering length. The function is applied with each i point coordinates (array) as input as .points[i,:3]. The return value is the corresponding scattering length.

Examples

# To select points inside of a sphere with radius 5 around [1,1,1]:
from numpy import linalg as la
sc=js.sf.scLattice(0.9,10)
sc.set_b(0)
sc.filter(lambda xyz: 1 if la.norm(xyz-np.r_[1,1,1])<5 else 0)

# sphere with  increase from center
from numpy import linalg as la
sc=js.sf.scLattice(0.9,10)
sc.set_b(0)
sc.filter(lambda xyz: 2*(la.norm(xyz)) if la.norm(xyz)<5 else 0)
fig=sc.show()
inParallelepiped(v1, v2, v3, corner=None, b=1, invert=False)[source]

Set scattering length for points in parallelepiped.

Parameters:
corner : 3x float

Corner of parallelepiped

v1,v2,v3 : each 3x float

Vectors from origin to 3 corners that define the parallelepiped.

b: float

Scattering length for selected points.

invert : bool

Invert selection

Examples

import jscatter as js
sc=js.sf.scLattice(0.2,10,b=[0])
sc.inParallelepiped([1,0,0],[0,1,0],[0,0,1],[0,0,0],1)
sc.show()
sc=js.sf.scLattice(0.1,30,b=[0])
sc.inParallelepiped([1,1,0],[0,1,1],[1,0,1],[-1,-1,-1],2)
sc.show()
inSphere(R, center=None, b=1, invert=False)[source]

Set scattering length for points in sphere.

Parameters:
center : 3 x float, default [0,0,0]

Center of the sphere.

R: float

Radius of sphere around origin.

b: float

Scattering length for selected points.

invert : bool

True to invert selection.

Examples

import jscatter as js
sc=js.sf.scLattice(1,15,b=[0])
sc.inSphere(6,[2,2,2],b=1)
sc.show()
sc.inSphere(6,[-2,-2,-2],b=2)
sc.show()

sc=js.sf.scLattice(0.8,20,b=[0])
sc.inSphere(3,[2,2,2],b=1)
sc.inSphere(3,[-2,-2,-2],b=1)
sc.show()

sc=js.sf.scLattice(0.8,20,b=[0])
sc.inSphere(3,[2,2,2],b=1)
sc.inSphere(4,[0,0,0],b=2)
sc.show()
move(vector)[source]

Move all points by vector.

Parameters:
vector : list of 3 float or array

Vector to shift the points.

numberOfAtoms()[source]

Number of Atoms

planeSide(vector, center=None, b=1, invert=False)[source]

Set scattering length for points on one side of a plane.

Parameters:
center : 3x float, default [0,0,0]

Point in plane.

vector : list 3x float

Vector perpendicular to plane.

b: float

Scattering length for selected points.

invert : bool

False choose points at origin side. True other side.

Examples

sc=js.sf.scLattice(1,10,b=[0])
sc.planeSide([1,1,1],[3,3,3],1)
sc.show()
sc.planeSide([-1,-1,0],3)
sc.show()
points

Points with scattering length >0

rotate(axis, angle)[source]

Rotate points in lattice around axis by angle.

Parameters:
axis : list 3xfloat

Axis of rotation

angle :

Rotation angle in rad

set_b(b)[source]

Set all initial points to given scattering length.

show(R=None, cmap='rainbow', fig=None, ax=None)[source]

Show the lattice in matplotlib with scattering length color coded.

Parameters:
R : float,None

Radius around origin to show.

cmap : colormap

Colormap. E.g. ‘rainbow’, ‘winter’,’autumn’,’gray’ Use js.mpl.showColors() for all possibilities.

Returns:
fig handle
type

Returns type of the lattice

class jscatter.structurefactor.rhombicLattice(latticeVectors, size, unitCellAtoms=None, b=None)[source]

Create a rhombic lattice with specified unit cell atoms.

Allows to create 1D, 2D or 3D latices by using 1, 2 or 3 latticeVectors.

Parameters:
latticeVectors : list of array 3x1

Lattice vectors defining the translation of the unit cell along its principal axes.

size :3x integer or integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

unitCellAtoms : list of 3x1 array, None=[0,0,0]

Position vectors vi of atoms in the unit cell in relative units of the lattice vectors [0<x<1]. For 2D and 1D the unit cell atoms vectors are len(vi)=2 and len(vi)=1.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array : grid points as numpy array .unitCellVolume : V = a1*a2 x a3 with latticeVectors a1, a2, a3; if existing. .dim : dimensionality .unitCellAtoms : Unit cell atoms in relative coordinates .unitCellAtoms_b : Scattering lngth of specific unit cell atoms

Examples

import jscatter as js
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# cubic lattice with diatomic base
grid=js.sf.rhombicLattice([[1,0,0],[0,1,0],[0,0,1]],[3,3,3],[[-0.1,-0.1,-0.1],[0.1,0.1,0.1]],[1,2])
grid.show(1.5)
getRadialReciprocalLattice(size, includeZero=False)[source]

Get radial distribution of Bragg peaks with structure factor and multiplicity.

Parameters:
size : int

Size of the lattice as maximum included Miller indices.

includeZero : bool

Include q=0 peak

Returns:
3x list of [unique q values, structure factor fhkl(q)**2, multiplicity mhkl(q)]
getReciprocalLattice(size=2)[source]

Reciprocal lattice of given size with peak scattering intensity.

Parameters:
size : 3x int or int, default 2

Number of reciprocal lattice points in each direction (+- direction).

Returns:
Array [N x 4] with

reciprocal lattice vectors [:,:3] corresponding structure factor fhkl**2>0 [:, 3]

rotateAroundhkl(hkl, angle=None, vector=None, hkl2=None)[source]

Rotate lattice around hkl direction by angle or to align to vector.

Uses angle or aligns hkl2 to vector. Includes rotation of latticeVectors.

Parameters:
hkl : 3x float

Direction given as Miller indices.

angle : float

Rotation angle in rad.

vector : 3x float

Vector to align hkl2 to. Overrides angle. Should not be parallel to hkl direction.

hkl2 : 3x float

Direction to align along vector. Overrides angle. Should not be parallel to hkl direction.

Examples

import jscatter as js
import numpy as np
import matplotlib.pyplot as plt
R=8
N=10
qxy=np.mgrid[-R:R:N*1j, -R:R:N*1j].reshape(2,-1).T
qxyz=np.c_[qxy,np.zeros(N**2)]
fccgrid = js.lattice.fccLattice(2.1, 1)
fig=plt.figure( )
# create subplot to define geometry
fig.add_subplot(2,2,1,projection='3d')
fccgrid.show(fig=fig,ax=1)
fccgrid.rotatehkl2Vector([1,1,1],[1,0,0])
fccgrid.show(fig=fig,ax=2)
fccgrid.rotateAroundhkl([1,1,1],np.deg2rad(30))
fccgrid.show(fig=fig,ax=3)
fccgrid.rotateAroundhkl([1,1,1],[1,0,0],[1,0,0])
fccgrid.show(fig=fig,ax=4)
rotatePlane2hkl(plane, hkl)[source]

Rotate plane points that plane is perpendicular to hkl direction.

Parameters:
plane : array Nx3

3D points of plane

hkl : list of int, float

Miller indices as [1,1,1] indicating the lattice direction where to rotate to.

Returns:
plane points array 3xN

Examples

import jscatter as js
import numpy as np
R=8
N=10
qxy=np.mgrid[-R:R:N*1j, -R:R:N*1j].reshape(2,-1).T
qxyz=np.c_[qxy,np.zeros(N**2)]
fccgrid = js.lattice.fccLattice(2.1, 3)
xyz=fccgrid.rotatePlane2hkl(qxyz,[1,1,1])
p=js.mpl.scatter3d(xyz[:,0],xyz[:,1],xyz[:,2])
p.axes[0].scatter(fccgrid.X,fccgrid.Y,fccgrid.Z)
rotatePlaneAroundhkl(plane, hkl, angle)[source]

Rotate plane points around hkl direction.

Parameters:
plane : array Nx3

3D points of plane

hkl : list of int, float

Miller indices as [1,1,1] indicating the lattice direction to rotate around.

angle : float

Angle in rad

Returns:
plane points array 3xN

Examples

import jscatter as js
import numpy as np
R=8
N=10
qxy=np.mgrid[-R:R:N*1j, -R:R:N*1j].reshape(2,-1).T
qxyz=np.c_[qxy,np.zeros(N**2)]
fccgrid = js.lattice.fccLattice(2.1, 1)
xyz=fccgrid.rotatePlane2hkl(qxyz,[1,1,1])
xyz2=fccgrid.rotatePlaneAroundhkl(xyz,[1,1,1],np.deg2rad(30))
p=js.mpl.scatter3d(xyz[:,0],xyz[:,1],xyz[:,2])
p.axes[0].scatter(xyz2[:,0],xyz2[:,1],xyz2[:,2])
p.axes[0].scatter(fccgrid.X,fccgrid.Y,fccgrid.Z)
rotatehkl2Vector(hkl, vector)[source]

Rotate lattice that hkl direction is parallel to vector.

Includes rotation of latticeVectors.

Parameters:
hkl : 3x float

Direction given as Miller indices.

vector : 3x float

Direction to align to.

Examples

import jscatter as js
import numpy as np
R=8
N=10
qxy=np.mgrid[-R:R:N*1j, -R:R:N*1j].reshape(2,-1).T
qxyz=np.c_[qxy,np.zeros(N**2)]
fccgrid = js.lattice.fccLattice(2.1, 1)
p=js.mpl.scatter3d(fccgrid.X,fccgrid.Y,fccgrid.Z)
fccgrid.rotatehkl2Vector([1,1,1],[1,0,0])
p.axes[0].scatter(fccgrid.X,fccgrid.Y,fccgrid.Z)
fccgrid.rotateAroundhkl([1,1,1],np.deg2rad(30))
p.axes[0].scatter(fccgrid.X,fccgrid.Y,fccgrid.Z)
unitCellAtomPositions

Absolute positions of unit cell atoms.

vectorhkl(hkl)[source]

Get vector corresponding to hkl direction.

Parameters:
hkl : 3x float

Miller indices

Returns:
array 3x float
class jscatter.structurefactor.bravaisLattice(latticeVectors, size, b=None)[source]

Create a Bravais lattice. Lattice with one atom in the unit cell.

See rhombicLattice for methods and attributes.

Parameters:
latticeVectors : list of array 1x3

Lattice vectors defining the translation of the unit cell along its principal axes.

size :3x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

class jscatter.structurefactor.scLattice(abc, size, b=None)[source]

Simple Cubic lattice.

See rhombicLattice for methods.

Parameters:
abc : float

Point distance.

size : 3x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
grid=js.sf.bccLattice(1.2,1)
grid.show(2)
class jscatter.structurefactor.bccLattice(abc, size, b=None)[source]

Body centered cubic lattice.

See rhombicLattice for methods.

Parameters:
abc : float

Point distance.

size : 3x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
grid=js.sf.bccLattice(1.2,1)
grid.show(2)
class jscatter.structurefactor.fccLattice(abc, size, b=None)[source]

Face centered cubic lattice.

See rhombicLattice for methods.

Parameters:
abc : float

Point distance.

size : 3x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
grid=js.sf.fccLattice(1.2,1)
grid.show(2)
class jscatter.structurefactor.hexLattice(ab, size, b=None)[source]

Simple 2D hexagonal lattice.

See rhombicLattice for methods.

Parameters:
ab : float

Point distance.

size : 2x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
grid=js.sf.hexLattice(1.2,1)
grid.show(2)
class jscatter.structurefactor.hcpLattice(ab, size, b=None)[source]

Hexagonal closed packed lattice.

See rhombicLattice for methods.

Parameters:
ab : float

Point distance. ab is distance in hexagonal plane, c = ab* (8/3)**0.5

size : 3x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
grid=js.sf.hcpLattice(1.2,[3,3,1])
grid.show(2)
class jscatter.structurefactor.diamondLattice(abc, size, b=None)[source]

Diamond cubic lattice with 8 atoms in unit cell.

See rhombicLattice for methods.

Parameters:
abc : float

Point distance.

size : 3x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
grid=js.sf.diamondLattice(1.2,1)
grid.show(2)
class jscatter.structurefactor.pseudoRandomLattice(size, numberOfPoints, b=None, seed=None)[source]

Create a lattice with a pseudo random distribution of points.

Allows to create 1D, 2D or 3D pseudo random latices. The Halton sequence is used with skipping the first seed elements of the Halton sequence.

Parameters:
size :3x float

Size of the lattice for each dimension relative to origin.

numberOfPoints : int

Number of points.

b : float,array

Scattering length of atoms. If array the sequence is repeated to fill N atoms.

seed : None, int

Seed for the Halton sequence by skipping the first seed elements of the sequence. If None an random integer between 10 and 1e6 is chosen.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
grid=js.sf.pseudoRandomLattice([5,5,5],3000)
fig=grid.show()
class jscatter.structurefactor.sqLattice(ab, size, b=None)[source]

Simple 2D square lattice.

See rhombicLattice for methods.

Parameters:
ab : float

Point distance.

size : 2x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
grid=js.sf.sqLattice(1.2,1)
grid.show(2)
class jscatter.structurefactor.lamLattice(a, size, b=None)[source]

1D lamellar lattice.

See rhombicLattice for methods.

Parameters:
a : float

Point distance.

size : 1x integer, integer

A list of integers describing the size in direction of the respective latticeVectors. Size is symmetric around zero in interval [-i,..,i] with length 2i+1. If one integer is given it is used for all 3 dimensions.

b : list of float

Corresponding scattering length of atoms in the unit cell.

Returns:
lattice object

.array grid points as numpy array

Examples

import jscatter as js
grid=js.sf.lamLattice(1.2,1)
grid.show(2)