sample.flayer - Functional layers¶
Functional magnetism profile. |
|
Generic profile function |
- class refl1d.sample.flayer.FunctionalMagnetism(profile=None, tol=0.001, name=None, **kw)[source]¶
Bases:
BaseMagnetism
Functional magnetism profile.
Parameters:
profile the profile function, suitably parameterized
tol is the tolerance for considering values equal
refl1d.sample.magnetism.BaseMagnetism
parametersThe profile function takes a depth vector z and returns a magnetism vector rhoM. For magnetic twist, return a pair of vectors (rhoM, thetaM). Constants can be returned for rhoM or thetaM. If thetaM is not provided it defaults to thetaM=270.
See
FunctionalProfile
for a description of the the profile function.- RESERVED = ('profile', 'tol', 'name', 'extent', 'dead_below', 'dead_above', 'interface_below', 'interface_above')¶
- dead_above: Parameter | Literal[None]¶
- dead_below: Parameter | Literal[None]¶
- extent: float¶
- interface_above: Parameter | Literal[None]¶
- interface_below: Parameter | Literal[None]¶
- magnetic = True¶
- name: str¶
- set_layer_name(name)¶
Update the names of the magnetic parameters with the name of the layer if it has not already been set. This is necessary since we don’t know the layer name until after we have constructed the magnetism object.
- class refl1d.sample.flayer.FunctionalProfile(thickness=0, interface=0, profile=None, tol=0.001, magnetism=None, name=None, **kw)[source]¶
Bases:
Layer
Generic profile function
Parameters:
thickness the thickness of the layer
interface the roughness of the surface [not implemented]
profile the profile function, suitably parameterized
tol is the tolerance for considering values equal
magnetism magnetic profile associated with the layer
name is the layer name
The profile function takes a depth vector z returns a density vector rho. For absorbing profiles, return complex vector rho + irho*1j.
Fitting parameters are the available named arguments to the function. The first argument is a depth vector, which is the array of depths at which the profile is to be evaluated. It is guaranteed to be increasing, with step size 2*z[0].
Initial values for the function parameters can be given using name=value. These values can be scalars or fitting parameters. The function will be called with the current parameter values as arguments. The layer thickness can be computed as
layer_thickness()
.There is no mechanism for querying the larger profile to determine the value of the rho at the layer boundaries. If needed, this information will have to be communicated through shared parameters. For example:
L1 = SLD('L1', rho=2.07) L3 = SLD('L3', rho=4) def linear(z, rhoL, rhoR): rho = z * (rhoR-rhoL)/(z[-1]-z[0]) + rhoL return rho profile = FunctionalProfile(100, 0, profile=linear, rhoL=L1.rho, rhoR=L3.rho) sample = L1 | profile | L3
- RESERVED = ('thickness', 'interface', 'profile', 'tol', 'magnetism', 'name')¶
- constraints()¶
Constraints
- find(z)¶
Find the layer at depth z.
Returns layer, start, end
- interface: Parameter | None = None¶
- property ismagnetic¶
- layer_parameters()¶
- magnetism: BaseMagnetism | None = None¶
- name: str¶
- parameters()[source]¶
Returns a dictionary of parameters specific to the layer. These will be added to the dictionary containing interface, thickness and magnetism parameters.
- penalty()¶
Return a penalty value associated with the layer. This should be zero if the parameters are valid, and increasing as the parameters become more invalid. For example, if total volume fraction exceeds unity, then the penalty would be the amount by which it exceeds unity, or if z values must be sorted, then penalty would be the amount by which they are unsorted.
Note that penalties are handled separately from any probability of seeing a combination of layer parameters; the final solution to the problem should not include any penalized points.
- thickness: Parameter¶