sample
BaseAssembly
Bases: BaseCore
Assembly of layers.
The front layer (front_layer) is the layer the neutron beam starts in, it has an index of 0. The back layer (back_layer) is the final layer from which the unreflected neutron beam is transmitted, its index number depends on the number of finite layers in the system, but it might be accessed at index -1.
Source code in src/easyreflectometry/sample/assemblies/base_assembly.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
type
property
Get type of the assembly.
Needed by the GUI.
front_layer
property
writable
Get the front layer in the assembly.
back_layer
property
writable
Get the back layer in the assembly.
conformal_thickness
property
writable
Whether every layer shares the front layer's thickness.
conformal_roughness
property
writable
Whether every layer shares the front layer's roughness.
Multilayer
Bases: BaseAssembly
A multi layer is build from a single or a list of Layer or LayerCollection.
The multi layer will arrange the layers as slabs, allowing the reflectometry to be determined from them. The front layer is where the neutron beam starts in, it has an index of 0.
More information about the usage of this assembly is available in the
multilayer documentation_
.. _multilayer documentation: ../sample/assemblies_library.html#multilayer
Source code in src/easyreflectometry/sample/assemblies/multilayer.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
__init__(layers=None, name='EasyMultilayer', unique_name=None, interface=None, type='Multi-layer', populate_if_none=True, conformal_thickness=False, conformal_roughness=False)
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
populate_if_none
|
Optional[bool]
|
By default, True. |
True
|
unique_name
|
Optional[str]
|
By default, None. |
None
|
layers
|
Union[Layer, list[Layer], LayerCollection, None]
|
The layers that make up the multi-layer. By default, None. |
None
|
name
|
str
|
Name for multi layer. By default, 'EasyMultilayer'. |
'EasyMultilayer'
|
interface
|
Calculator interface. By default, None. |
None
|
|
type
|
str
|
Type of the constructed instance. By default, 'Multi-layer'. |
'Multi-layer'
|
conformal_thickness
|
bool
|
Tie every layer's thickness to the front layer's. Serialization
reads the current graph state through the matching property, so
the ties are rebuilt on |
False
|
conformal_roughness
|
bool
|
Tie every layer's roughness to the front layer's, likewise persistent. By default, False. |
False
|
Source code in src/easyreflectometry/sample/assemblies/multilayer.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
add_layer(*layers)
Add a layer to the multi layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*layers
|
tuple[Layer]
|
Layers to add to the multi layer. |
()
|
Source code in src/easyreflectometry/sample/assemblies/multilayer.py
86 87 88 89 90 91 92 93 94 95 96 97 98 | |
duplicate_layer(idx)
Duplicate a given layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
Index of layer to duplicate. |
required |
Source code in src/easyreflectometry/sample/assemblies/multilayer.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
remove_layer(idx)
Remove a layer from the item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
Index of layer to remove. |
required |
Source code in src/easyreflectometry/sample/assemblies/multilayer.py
117 118 119 120 121 122 123 124 125 126 127 | |
from_dict(data)
classmethod
Create a Multilayer from a dictionary.
Source code in src/easyreflectometry/sample/assemblies/multilayer.py
135 136 137 138 139 | |
RepeatingMultilayer
Bases: Multilayer
A repeating multi layer is build from a Multilayer and which it repeats
for a given number of times. This enables a computational efficiency in many
reflectometry engines as the operation can be performed for a single
Multilayer and cheaply combined for the appropriate number of
repetitions.
More information about the usage of this assembly is available in the
repeating multilayer documentation_
.. _repeating multilayer documentation: ../sample/assemblies_library.html#repeatingmultilayer
Source code in src/easyreflectometry/sample/assemblies/repeating_multilayer.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
__init__(layers=None, repetitions=None, name='EasyRepeatingMultilayer', unique_name=None, interface=None, populate_if_none=True, conformal_thickness=False, conformal_roughness=False)
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
populate_if_none
|
bool
|
By default, True. |
True
|
unique_name
|
Optional[str]
|
By default, None. |
None
|
layers
|
Union[LayerCollection, Layer, list[Layer], None]
|
The layers that make up the multi-layer that will be repeated. By default, None. |
None
|
repetitions
|
Union[Parameter, int, None]
|
Number of repetitions of the given series of layers. By default, None. |
None
|
name
|
str
|
Name for the repeating multi layer. By default, 'EasyRepeatingMultilayer'. |
'EasyRepeatingMultilayer'
|
interface
|
Calculator interface. By default, None. |
None
|
|
conformal_thickness
|
bool
|
Tie every layer's thickness to the front layer's (persisted). By default, False. |
False
|
conformal_roughness
|
bool
|
Tie every layer's roughness to the front layer's (persisted). By default, False. |
False
|
Source code in src/easyreflectometry/sample/assemblies/repeating_multilayer.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
SurfactantLayer
Bases: BaseAssembly
A surfactant layer constructs a series of layers representing the head and tail groups of a surfactant. This assembly allows the definition of a surfactant or lipid using the chemistry of the head (head_layer) and tail (tail_layer) regions, additionally this approach will make the application of constraints such as conformal roughness or area per molecule more straight forward.
More information about the usage of this assembly is available in the
surfactant documentation_
.. _surfactant documentation: ../sample/assemblies_library.html#surfactantlayer
Source code in src/easyreflectometry/sample/assemblies/surfactant_layer.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
constrain_area_per_molecule
property
writable
Get the area per molecule constraint status.
tail_layer
property
writable
Get the tail layer of the surfactant surface.
head_layer
property
writable
Get the head layer of the surfactant surface.
conformal_roughness
property
writable
Get the roughness constraint status.
__init__(tail_layer=None, head_layer=None, name='EasySurfactantLayer', unique_name=None, constrain_area_per_molecule=False, conformal_roughness=False, interface=None)
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unique_name
|
Optional[str]
|
By default, None. |
None
|
tail_layer
|
Optional[LayerAreaPerMolecule]
|
Layer representing the tail part of the surfactant layer. By default, None. |
None
|
head_layer
|
Optional[LayerAreaPerMolecule]
|
Layer representing the head part of the surfactant layer. By default, None. |
None
|
name
|
str
|
Name for surfactant layer. By default, 'EasySurfactantLayer'. |
'EasySurfactantLayer'
|
constrain_area_per_molecule
|
bool
|
Constrain the area per molecule. By default, False. |
False
|
conformal_roughness
|
bool
|
Constrain the roughness to be the same for both layers. By default, False. |
False
|
interface
|
Calculator interface. By default, None. |
None
|
Source code in src/easyreflectometry/sample/assemblies/surfactant_layer.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
constrain_solvent_roughness(solvent_roughness)
Add the constraint to the solvent roughness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solvent_roughness
|
Parameter
|
The solvent roughness parameter. |
required |
Source code in src/easyreflectometry/sample/assemblies/surfactant_layer.py
192 193 194 195 196 197 198 199 200 201 202 203 | |
constrain_multiple_contrast(another_contrast, head_layer_thickness=True, tail_layer_thickness=True, head_layer_area_per_molecule=True, tail_layer_area_per_molecule=True, head_layer_fraction=True, tail_layer_fraction=True)
Constrain structural parameters between surfactant layer objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tail_layer_fraction
|
bool
|
By default, True. |
True
|
head_layer_fraction
|
bool
|
By default, True. |
True
|
tail_layer_area_per_molecule
|
bool
|
By default, True. |
True
|
head_layer_area_per_molecule
|
bool
|
By default, True. |
True
|
tail_layer_thickness
|
bool
|
By default, True. |
True
|
head_layer_thickness
|
bool
|
By default, True. |
True
|
another_contrast
|
SurfactantLayer
|
The surfactant layer to constrain. |
required |
Source code in src/easyreflectometry/sample/assemblies/surfactant_layer.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
to_dict(skip=None)
Serialize, dropping the derived layers field (it is rebuilt
from tail_layer and head_layer in __init__).
Source code in src/easyreflectometry/sample/assemblies/surfactant_layer.py
264 265 266 267 268 269 270 | |
Layer
Bases: BaseCore
Source code in src/easyreflectometry/sample/elements/layers/layer.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
rho_m_coupled
property
writable
Whether the layer's magnetic SLD is the material's rho_m
(a :class:~easyreflectometry.sample.MaterialMagnetic).
When True, magnetism.rho_m is a dependent parameter following the
current material; the layer keeps its own theta_m. Opt-in: layers of
one material may carry different net moments. Setting it attaches a
default :class:LayerMagnetism when the layer has none, and requires a
material with rho_m. Uncoupling keeps the current value. Removing
the magnetism, or a user unconstrain of rho_m, uncouples.
Only the layer's own wiring counts: a user constraint placed on
rho_m (:func:~easyreflectometry.constraints.constrain) reads as
uncoupled, is saved as the user constraint it is, and is left alone
when the material is later replaced. Setting this to True explicitly
replaces such a constraint with the coupling.
__init__(material=None, thickness=None, roughness=None, name='EasyLayer', unique_name=None, interface=None, magnetism=None, rho_m_coupled=False)
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unique_name
|
Optional[str]
|
By default, None. |
None
|
material
|
Union[Material, None]
|
The material for the layer. By default, None. |
None
|
thickness
|
Union[Parameter, float, None]
|
Layer thickness in Angstrom. By default, None. |
None
|
roughness
|
Union[Parameter, float, None]
|
Upper roughness on the layer in Angstrom. By default, None. |
None
|
magnetism
|
Union[LayerMagnetism, None]
|
Magnetic properties of the layer; None for a non-magnetic layer. By default, None. |
None
|
rho_m_coupled
|
bool
|
Take the magnetic SLD from the material (see :attr: |
False
|
name
|
str
|
Name of the layer. By default, 'EasyLayer'. |
'EasyLayer'
|
interface
|
Interface object. By default, None. |
None
|
Source code in src/easyreflectometry/sample/elements/layers/layer.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
interface(new_interface)
Set the interface; runs generate_bindings and, for a magnetic layer,
enables magnetism on the calculator (raising if it does not support it).
Source code in src/easyreflectometry/sample/elements/layers/layer.py
115 116 117 118 119 120 121 122 | |
assign_material(material)
Assign a material to the layer interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
Material
|
The material to assign to the layer. |
required |
Source code in src/easyreflectometry/sample/elements/layers/layer.py
258 259 260 261 262 263 264 265 266 267 268 269 270 | |
VolumeFractionProfile
dataclass
Volume fraction of every component of a sample versus depth.
Attributes:
| Name | Type | Description |
|---|---|---|
z |
np.ndarray
|
Depth in Å; |
fractions |
dict
|
Component key -> |
labels |
dict
|
Component key -> display label, unique within the profile. |
Source code in src/easyreflectometry/sample/volume_fraction.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
components
property
The component keys, front to back.
total
property
sum_c phi_c(z); ones up to floating point error.
grouped(groups)
Merge components into named groups for presentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
groups
|
Mapping[str, Sequence[str]]
|
Group label -> members, given as component keys or labels, e.g.
|
required |
Returns:
| Type | Description |
|---|---|
VolumeFractionProfile
|
A new profile; this one is left unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
A member is unknown, a component is listed twice, a group is empty, or a group label collides with a retained component. |
Source code in src/easyreflectometry/sample/volume_fraction.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
BaseCollection
Bases: EasyList
Local base for sample-tree collections (Material/Layer/Assembly/Model collections).
Built on top of easyscience.base_classes.EasyList (the replacement for
the deprecated CollectionBase). On top of EasyList this class adds:
- a
nameproperty - an
interfaceproperty whose setter propagates the calculator interface to every contained item - propagation of the current
interfaceto newly inserted items - a
populate_if_noneflag preserved for serialization round-trip - convenience helpers
names,move_up,move_down,remove_at - a yaml-formatted
__repr__driven by_dict_repr - an
as_dictalias forto_dictwithskip=support andinterfaceexcluded by default
Subclasses (LayerCollection, MaterialCollection, Sample,
ModelCollection) keep their existing constructor shape — they pass
name and interface positionally to this class, items as *args, and
additional configuration as kwargs.
Source code in src/easyreflectometry/sample/collections/base_collection.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
names
property
List of item names.
data
property
Read-only view of the underlying item list.
Provided for compatibility with code (and tests) written against the
legacy CollectionBase shape, which exposed items via .data.
insert(index, value)
Insert and (if an interface is set) propagate it to the new item.
Legacy CollectionBase.insert did value.interface = self.interface
after registering the item; we replicate the same behaviour here so
downstream calculator state stays in sync when items are appended
after the collection's interface was already set.
The type check from EasyList.insert is bypassed: each subclass
accepts a single item type (Layer / Material / BaseAssembly / Model)
and enforces it elsewhere, while the EasyList check would require
every item to be a NewBase subclass — which was historically not
guaranteed and forces an extra coupling we don't need.
Source code in src/easyreflectometry/sample/collections/base_collection.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
move_up(index)
Move the element at the given index up in the collection.
Source code in src/easyreflectometry/sample/collections/base_collection.py
172 173 174 175 176 | |
move_down(index)
Move the element at the given index down in the collection.
Source code in src/easyreflectometry/sample/collections/base_collection.py
178 179 180 181 182 | |
remove_at(index)
Remove the item at index from the collection.
Renamed from the legacy BaseCollection.remove(index) which shadowed
MutableSequence.remove(value) (remove-by-value, inherited from
EasyList). Callers that meant "remove by index" should use this; the
standard remove(value) is still available with its usual semantics.
Source code in src/easyreflectometry/sample/collections/base_collection.py
184 185 186 187 188 189 190 191 192 | |
get_parameters()
Compatibility alias for legacy callers; prefer get_all_parameters.
Source code in src/easyreflectometry/sample/collections/base_collection.py
196 197 198 | |
get_all_variables()
Flat list of every Parameter/Descriptor across all items.
Walks each item in the collection and unions whatever each item
exposes via its own get_all_variables (for ModelBase /
BaseCore children) or, for objects that lack that hook,
unions any direct DescriptorBase attributes.
Source code in src/easyreflectometry/sample/collections/base_collection.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
get_fit_parameters()
Alias kept for the minimizer; matches ModelBase.get_fit_parameters.
Source code in src/easyreflectometry/sample/collections/base_collection.py
230 231 232 | |
to_dict(skip=None)
Serialize with skip support; interface excluded by default.
EasyList.to_dict doesn't accept a skip argument and is hard-wired
to dump data plus the parent's _arg_spec view. We reimplement here
so existing callers (Project, Model.as_dict, etc.) can keep
passing skip=['unique_name'] or similar.
NewBase.to_dict mutates the skip list in-place (e.g. it
appends 'unique_name' when the collection's own unique_name is
default-generated). We therefore pass a copy to it, otherwise the
mutation would leak into the per-item serialization below and force
every item Parameter dict to drop its unique_name — breaking the
from_dict round-trip.
Source code in src/easyreflectometry/sample/collections/base_collection.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
as_dict(skip=None)
Compatibility alias for :meth:to_dict.
Source code in src/easyreflectometry/sample/collections/base_collection.py
327 328 329 | |
from_dict(obj_dict)
classmethod
Rebuild the collection, each item through its own class's from_dict.
EasyList.from_dict deserializes the data list with the
serializer's generic path, which calls every item's constructor with
the stored keys. An item whose class restores state in from_dict
(e.g. MaterialDensity and its sld_coupled key, or any nested
item that does) then fails or loses that state. Apart from the items,
this mirrors EasyList.from_dict.
Source code in src/easyreflectometry/sample/collections/base_collection.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
__deepcopy__(memo)
Round-trip via dict-skip-unique to get a fresh copy.
NewBase.__copy__ already does this; the override is kept (rather
than deleted) to mirror the legacy BaseCollection.__deepcopy__
semantics — callers that relied on copy.deepcopy(collection) still
get a clone built from from_dict(as_dict(skip=['unique_name'])).
Source code in src/easyreflectometry/sample/collections/base_collection.py
362 363 364 365 366 367 368 369 370 | |
Sample
Bases: BaseCollection
A sample is a collection of assemblies that represent the structure for which experimental measurements exist.
Source code in src/easyreflectometry/sample/collections/sample.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
superphase
property
The superphase of the sample.
subphase
property
The subphase of the sample.
__init__(*assemblies, name='EasySample', interface=None, unique_name=None, populate_if_none=True, **kwargs)
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
|
{}
|
|
populate_if_none
|
bool
|
By default, True. |
True
|
unique_name
|
Optional[str]
|
By default, None. |
None
|
*assemblies
|
Optional[List[BaseAssembly]]
|
The assemblies in the sample. |
()
|
name
|
str
|
Name of the sample. By default, 'EasySample'. |
'EasySample'
|
interface
|
Calculator interface. By default, None. |
None
|
Source code in src/easyreflectometry/sample/collections/sample.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
add_assembly(assembly=None)
Add an assembly to the sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assembly
|
Optional[BaseAssembly]
|
Assembly to add. By default, None. |
None
|
Source code in src/easyreflectometry/sample/collections/sample.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
duplicate_assembly(index)
Duplicate an assembly of the sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the assembly to duplicate. |
required |
Source code in src/easyreflectometry/sample/collections/sample.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
move_up(index)
Move the assembly at the given index up in the sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the assembly to move up. |
required |
Source code in src/easyreflectometry/sample/collections/sample.py
120 121 122 123 124 125 126 127 128 | |
move_down(index)
Move the assembly at the given index down in the sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the assembly to move down. |
required |
Source code in src/easyreflectometry/sample/collections/sample.py
130 131 132 133 134 135 136 137 138 | |
remove_assembly(index)
Remove the assembly at the given index from the sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the assembly to remove. |
required |
Source code in src/easyreflectometry/sample/collections/sample.py
140 141 142 143 144 145 146 147 148 | |
volume_fraction_profile(z=None, *, max_delta_z=None, merge_equivalent=True)
Volume fraction (occupancy) of every component of the sample versus depth.
A thin wrapper around :func:easyreflectometry.sample.volume_fraction.volume_fraction_profile;
see there for the parameters, the depth convention and the caveats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
np.ndarray
|
Depths (Å) to evaluate at; |
None
|
max_delta_z
|
float
|
Maximum spacing of the default grid. Cannot be combined with |
None
|
merge_equivalent
|
bool
|
Merge materials with equal name and SLD into one component. By default, True. |
True
|
Returns:
| Type | Description |
|---|---|
VolumeFractionProfile
|
The per-component profiles, summing to one at every depth. |
Source code in src/easyreflectometry/sample/collections/sample.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
volume_fraction_profile(sample, z=None, *, max_delta_z=None, merge_equivalent=True)
Erf-smeared volume fraction of every component of sample versus depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Sample
|
The sample. It does not need to be bound to a calculator. |
required |
z
|
np.ndarray
|
Depths (Å) at which to evaluate the profile, |
None
|
max_delta_z
|
float
|
Maximum spacing of the default grid; raises the point count above
:data: |
None
|
merge_equivalent
|
bool
|
Merge materials the calculator cannot tell apart (equal name, SLD and
imaginary SLD) into one component, so that the several default solvent
objects of a bilayer come out as one "D2O" trace and its two head
groups as one trace. |
True
|
Returns:
| Type | Description |
|---|---|
VolumeFractionProfile
|
The profile. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The sample has fewer than two layers, both |
Warns:
| Type | Description |
|---|---|
VolumeFractionWarning
|
A fraction dips below |
Source code in src/easyreflectometry/sample/volume_fraction.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
DEFAULT_ELEMENTS(interface)
:meta private:.
Source code in src/easyreflectometry/sample/collections/sample.py
22 23 24 25 26 27 | |