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 described in [1]_ (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[, a, domainsize, …]) Structure factor of a crystal lattice with particle asymmetry, DebyeWaller factor, diffusive scattering and domain size.

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

Explicit creating of particle lattice.

bravaisLattice(latticeVectors, size) Create a bravais lattice.
scLattice(abc, size) Simple Cubic lattice.
bccLattice(abc, size[, b]) Body centered cubic lattice.
fccLattice(abc, size) Face centered cubic lattice.
hexLattice(ab, c, size) Hexagonal lattice.
hcpLattice(ab, size) Hexagonal closed packed lattice.
rhombicLattice(latticeVectors, size[, …]) Create a rhombic lattice.
rhombicLattice.X X coordinates
rhombicLattice.Y Y coordinates
rhombicLattice.Z Z coordinates
rhombicLattice.b Scattering length
rhombicLattice.filter(funktion) Filter lattice points according to a function.
rhombicLattice.centerOfMass() CenterOf mass
rhombicLattice.numberOfAtoms() Number of Atoms
rhombicLattice.planeSide(vector[, invert]) Select points on one side of a plane.
rhombicLattice.move(vector) Move all points by vector.
rhombicLattice.inSphere(R) Choose lattice points in sphere
rhombicLattice.show([R]) Show the lattice in matplotlib.
rhombicLattice.limit2Cube(a, b, c) Cut at cube with edges at

Lattice objects describing a lattice of points.

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

The small angle scattering can 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.

Examples

A hollow sphere cut to a wedge.

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

q=js.loglist(0.01,5,300)
ffe=js.ff.cloudScattering(q,grid.points,relError=50,rms=0.1)
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 described in [1]_ (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 [R227]; solution in [R228] and best description of the solution is in [R229].

References

[R227](1, 2)
    1. Percus and G. J. Yevick, Phys. Rev. 110, 1 (1958).
[R228](1, 2)
    1. Wertheim, Phys. Rev. Lett. 10, 321 (1963).
[R229](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

[R230]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
[R231]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:

dataArary

References

[R232]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 [R233] [R234] . 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 [R233] (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. Overides 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 somtimes not good enough this results in an arbitrary root of the quartic in the Newton algorithm. The solution therefore jumps between different posibilities by small changes of the parameters. We use here the original idea from [R233] 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 [R235] for details.

References

[R233](1, 2, 3, 4)
    1. Hayter and J. Penfold, Mol. Phys. 42, 109 (1981).
[R234](1, 2) J.-P. Hansen and J. B. Hayter, Mol. Phys. 46, 651 (2006).
[R235](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

[R236]
  1. Regnaut and J. C. Ravey, J. Chem. Phys. 91, 1211 (1989).
[R237]
  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 Yevik structure factor S_OZ this function

References

[R238]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.

We use the theory from Beenakker and Mazur [R240] as given by Genz [R239]. 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 overides 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-Yevik 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 overwriten 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 [R239] and therfore 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 [R239] 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

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

Structure factor of a crystal lattice with particle asymmetry, DebyeWaller factor, diffusive scattering and domain size.

This is the structure factor S(q) in equ 30 of [R242]. \Omega_d omitted To get the full scattering the formfactor needs to be included (See Notes and module formfactor).

Parameters:

q : float

Wavevector, units 1/A or 1/nm

a : float

Lattice constant, units as 1/[q units]

domainsize : float

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

type : ‘lam’, ‘sq’, ‘hex’, ‘sc’, ‘bcc’, ‘fcc’, ‘hcp’

Type of the crystal structure.
  • sc simple cubic
  • bcc body centered cubic
  • fcc face centered cubic
  • hcp hexagonally close packing
  • hex 2D-hexagonal packing
  • sq 2D-square packing
  • lam 1D-packing

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 2*fwhm/(1+np.exp(asym*(x-center))) For a=0 the Voigt is symmetric with fwhm. See formel.voigt .

rmsd : float, default=0.02

Root mean square displacement <u^2>^0.5 determining the Debye Waller factor. Units as a.

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 [R242] 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.

c : float, default=1

Porod constant. See 3.8 in [R242].

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) assymmetry factor of the formfactor.
  • Z0q lattice factor Z0(q)
Attributes
  • .q_hkl peak positions
  • .hkl Miller indices
  • .fhkl symmetry factor
  • .mhkl multiplicity
  • .dnn next neighbour distance

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 inhomogenious particles we can incorporate \Delta\rho(r) in the formfactor P(q) if this includes the integrated scattering length differences.

  • The structure factor is

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

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

    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} symmetry 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 limitting behaviour q->0 see the discussion in [R242] in 3.9. :

    “… The zero-order peak is not explicitely 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

[R242](1, 2, 3, 4, 5) Scattering curves of ordered mesoscopic materials. Förster, S. et al. J. Phys. Chem. B 109, 1347–1360 (2005).
[R243](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.
[R244](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):
    hex = js.sf.latticeStructureFactor(q, a=a, rmsd=rmsd , domainsize=500., beta=beta,type='hex')
    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)
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 [R246] 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

[R245]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.
[R246](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 [R247].

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) stickyness=exp(-depth)/12./eps

References

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

Create a rhombic lattice.

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

Parameters:

latticeVectors : list of array 3x1

Lattice primitive 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.

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

Position vectors of atoms in the primitive cell.

b : list of float

Corresponding scattering length of atoms in the primitive cell.

Returns:

lattice object

.array grid points as numpy array .primitiveVolume V = a1*a2 x a3 with latticeVectors a1, a2, a3; if existing.

Examples

import jscatter as js
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# cubic lattice with diatomic base
grid=js.lattice.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])
#
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#
ax.scatter(grid.X,grid.Y,grid.Z,color="k",s=20)
ax.set_xlim([-5,5])
ax.set_ylim([-5,5])
ax.set_zlim([-5,5])
ax.set_aspect("equal")
plt.tight_layout()
plt.show(block=False)
X

X coordinates

Y

Y coordinates

Z

Z coordinates

array

Coordinates and scattering length as array

b

Scattering length

centerOfMass()[source]

CenterOf mass

filter(funktion)[source]

Filter lattice points according to a function.

The existing points in the lattice size are tested.

Parameters:

funktion : function returning bool

Function to select lattice points. The function is applied with the point coordinates (array) as input. This corresponds to .points[:,:3]

Returns:

array

Examples

To select points inside of a sphere with radius 50 around [0,0,0]:

grid.filter(lambda xyz: np.sum(xyz**2)<50**2)
inSphere(R)[source]

Choose lattice points in sphere

Parameters:

R: float

Radius of sphere around origin. If negative the points outside are choosen

limit2Cube(a, b, c)[source]

Cut at cube with edges at

Parameters:

a,b,c : float

Cut at +-[a,0,0],+-[0,b,0],+-[0,0,c]

move(vector)[source]

Move all points by vector. Parameters ———- vector : list of float

Vector to shift the points.
numberOfAtoms()[source]

Number of Atoms

planeSide(vector, invert=False)[source]

Select points on one side of a plane.

Parameters:

vector : list 3x float

Vector from origin to plane, perpendicular to plane.

invert : bool

False choose points at origin side. True other side.

show(R=None)[source]

Show the lattice in matplotlib.

Parameters:

R : float,None

Radius around origin to show.

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

Create a rhombic lattice.

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

Parameters:

latticeVectors : list of array 3x1

Lattice primitive 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.

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

Position vectors of atoms in the primitive cell.

b : list of float

Corresponding scattering length of atoms in the primitive cell.

Returns:

lattice object

.array grid points as numpy array .primitiveVolume V = a1*a2 x a3 with latticeVectors a1, a2, a3; if existing.

Examples

import jscatter as js
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# cubic lattice with diatomic base
grid=js.lattice.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])
#
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#
ax.scatter(grid.X,grid.Y,grid.Z,color="k",s=20)
ax.set_xlim([-5,5])
ax.set_ylim([-5,5])
ax.set_zlim([-5,5])
ax.set_aspect("equal")
plt.tight_layout()
plt.show(block=False)
class jscatter.structurefactor.bravaisLattice(latticeVectors, size)[source]

Create a bravais lattice. Lattice with one atom in the primitive cell.

See rhombicLattice for methods and attributes.

Parameters:

latticeVectors : list of array 1x3

Lattice primitive 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.

Returns:

lattice object

.array grid points asnumpy array

class jscatter.structurefactor.scLattice(abc, size)[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.

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.lattice.bccLattice(1.2,1).array
#
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#
ax.scatter(grid[:,0],grid[:,1],grid[:,2],color="k",s=20)
ax.set_xlim([-5,5])
ax.set_ylim([-5,5])
ax.set_zlim([-5,5])
ax.set_aspect("equal")
plt.tight_layout()
plt.show(block=False)
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.

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.lattice.bccLattice(1.2,1).array
#
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#
ax.scatter(grid[:,0],grid[:,1],grid[:,2],color="k",s=20)
ax.set_xlim([-5,5])
ax.set_ylim([-5,5])
ax.set_zlim([-5,5])
ax.set_aspect("equal")
plt.tight_layout()
plt.show(block=False)
class jscatter.structurefactor.fccLattice(abc, size)[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.

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.lattice.fccLattice(1.2,1).array
#
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#
ax.scatter(grid[:,0],grid[:,1],grid[:,2],color="k",s=20)
ax.set_xlim([-5,5])
ax.set_ylim([-5,5])
ax.set_zlim([-5,5])
ax.set_aspect("equal")
plt.tight_layout()
plt.show(block=False)
class jscatter.structurefactor.hexLattice(ab, c, size)[source]

Hexagonal lattice.

See rhombicLattice for methods.

Parameters:

ab,c : float

Point distance. ab is distance in hexagonal plane, c perpendicular. For c/a = (8/3)**0.5 the hcp structure

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.

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.lattice.hexLattice(1.,2,[2,2,2]).array
#
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(grid[:,0],grid[:,1],grid[:,2],color="k",s=20)
ax.set_xlim([-5,5])
ax.set_ylim([-5,5])
ax.set_zlim([-5,5])
ax.set_aspect("equal")
plt.tight_layout()
plt.show(block=False)
class jscatter.structurefactor.hcpLattice(ab, size)[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.

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.lattice.hcpLattice(1.2,[3,3,1]).array
#
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#
ax.scatter(grid[:,0],grid[:,1],grid[:,2],color="k",s=20)
ax.set_xlim([-5,5])
ax.set_ylim([-5,5])
ax.set_zlim([-5,5])
ax.set_aspect("equal")
plt.tight_layout()
plt.show(block=False)