mixscatter API
mixscatter.core
This module provides convenience functions for calculating the scattered intensity, measurable structure factors and apparent diffusion coefficients for a given scattering model and liquid structure.
Classes:
| Name | Description |
|---|---|
LiquidStructureLike |
A protocol which defines an interface for a class which behaves like |
ScatteringModelLike |
A protocol which defines an interface for a class which behaves like |
MixtureLike |
A protocol which defines an interface for a class which behaves like |
Functions:
| Name | Description |
|---|---|
measurable_intensity |
Calculate the measured intensity for a given scattering model and liquid structure. |
measurable_structure_factor |
Calculate the measurable structure factor for a given scattering model and liquid structure. |
measurable_diffusion_coefficient |
Calculate the measured diffusion coefficient for a given scattering model and liquid |
LiquidStructureLike
Bases: Protocol
A protocol which defines an interface for a class which behaves like LiquidStructure.
Any object which implements this protocol can be used by the functions in this module instead of a standard
LiquidStructure object. This can be exploited to construct custom LiquidStructureLike objects with
only the functionality strictly necessary.
Source code in src/mixscatter/core.py
MixtureLike
Bases: Protocol
A protocol which defines an interface for a class which behaves like Mixture.
Any object which implements this protocol can be used by the functions in this module instead of a standard
Mixture object. This can be exploited to construct custom MixtureLike objects with
only the functionality strictly necessary.
Source code in src/mixscatter/core.py
ScatteringModelLike
Bases: Protocol
A protocol which defines an interface for a class which behaves like ScatteringModel.
Any object which implements this protocol can be used by the functions in this module instead of a standard
ScatteringModel object. This can be exploited to construct custom ScatteringModelLike objects with
only the functionality strictly necessary.
Source code in src/mixscatter/core.py
measurable_diffusion_coefficient(scattering_model, thermal_energy, viscosity)
Calculate the measurable Stokes-Einstein diffusion coefficient of a dilute suspension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scattering_model
|
ScatteringModelLike
|
|
required |
thermal_energy
|
float
|
Thermal energy. |
required |
viscosity
|
float
|
Viscosity of the surrounding medium. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Measurable diffusion coefficient. |
Examples:
>>> import numpy as np
>>> from mixscatter import Mixture, SimpleSphere, measurable_diffusion_coefficient
>>> wavevector = np.linspace(0.005, 0.05, 100)
>>> mixture = Mixture([100, 200], [0.2, 0.8])
>>> scattering_model = SimpleSphere(wavevector, mixture, contrast=1.0)
>>> D_0 = measurable_diffusion_coefficient(
... scattering_model, thermal_energy=1.0, viscosity=1.0
... )
Source code in src/mixscatter/core.py
measurable_intensity(liquid_structure, scattering_model, scale=1.0, background=0.0)
Calculate the measured intensity for a given scattering model and liquid structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
liquid_structure
|
LiquidStructureLike
|
|
required |
scattering_model
|
ScatteringModelLike
|
|
required |
scale
|
float
|
Scale the intensity by a factor. |
1.0
|
background
|
float
|
Add a constant background. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Measurable scattered intensity. |
Examples:
>>> import numpy as np
>>> from mixscatter import Mixture, PercusYevick, SimpleSphere, measurable_intensity
>>> liquid_structure = PercusYevick(wavevector, mixture, volume_fraction_total=0.3)
>>> scattering_model = SimpleSphere(wavevector, mixture, contrast=1.0)
>>> intensity = measurable_intensity(
... liquid_structure, scattering_model, scale=1e5, background=1e3
... )
Source code in src/mixscatter/core.py
measurable_structure_factor(liquid_structure, scattering_model)
Calculate the measurable structure factor for a given scattering model and liquid structure.
This is the quotient of the measurable intensity of a system with interactions and the equivalent intensity of a system without interactions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
liquid_structure
|
LiquidStructureLike
|
|
required |
scattering_model
|
ScatteringModelLike
|
|
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Measurable structure factor. |
Examples:
>>> import numpy as np
>>> from mixscatter import Mixture, PercusYevick, SimpleSphere, measurable_structure_factor
>>> liquid_structure = PercusYevick(wavevector, mixture, volume_fraction_total=0.3)
>>> scattering_model = SimpleSphere(wavevector, mixture, contrast=1.0)