sample_model
BackgroundModel
Bases: ModelBase
BackgroundModel represents a model of the background in an experiment at various Q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyBackgroundModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
Q_type | None
|
Q values for the model. If None, Q is not set. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the model. |
components |
list[ModelComponent]
|
List of ModelComponents in the model. |
Q |
ndarray | Numeric | list | ArrayLike | Variable | None
|
Q values of the model. |
Source code in src/easydynamics/sample_model/background_model.py
13 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 | |
__init__(display_name='MyBackgroundModel', unique_name=None, unit='meV', components=None, Q=None)
Initialize the BackgroundModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyBackgroundModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
Q_type | None
|
Q values for the model. If None, Q is not set. |
None
|
Source code in src/easydynamics/sample_model/background_model.py
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 | |
BrownianTranslationalDiffusion
Bases: DiffusionModelBase
Model of Brownian translational diffusion, consisting of a Lorentzian function for each Q-value, where the width is given by \(D Q^2\), where \(D\) is the diffusion coefficient. The area of the Lorentzians is given by the scale parameter multiplied by the QISF, which is 1 for this model. The EISF is 0 for this model, so there is no delta function component. Q is assumed to have units of 1/angstrom. Creates ComponentCollections with Lorentzian components for given Q-values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'BrownianTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the diffusion model. |
scale |
Parameter
|
Scale parameter of the diffusion model. |
diffusion_coefficient |
Parameter
|
Diffusion coefficient D in m^2/s. |
Example usage:
Q=np.linspace(0.5,2,7) energy=np.linspace(-2, 2, 501) scale=1.0 diffusion_coefficient = 2.4e-9 # m^2/s diffusion_model=BrownianTranslationalDiffusion(display_name="DiffusionModel", scale=scale, diffusion_coefficient= diffusion_coefficient) component_collections=diffusion_model.create_component_collections(Q) See also the examples.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
__init__(display_name='BrownianTranslationalDiffusion', unique_name=None, unit='meV', scale=1.0, diffusion_coefficient=1.0)
Initialize a new BrownianTranslationalDiffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'BrownianTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If scale or diffusion_coefficient is not a number. |
ValueError
|
If scale is negative. |
UnitError
|
If unit is not a string or scipp Unit. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
__repr__()
String representation of the BrownianTranslationalDiffusion model.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String representation of the BrownianTranslationalDiffusion model. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
333 334 335 336 337 338 339 340 341 342 343 344 | |
calculate_EISF(Q)
Calculate the Elastic Incoherent Structure Factor (EISF) for the Brownian translational diffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: EISF values (dimensionless). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
calculate_QISF(Q)
Calculate the Quasi-Elastic Incoherent Structure Factor (QISF).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: QISF values (dimensionless). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
calculate_width(Q)
Calculate the half-width at half-maximum (HWHM) for the diffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: HWHM values in the unit of the model (e.g., meV). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
create_component_collections(Q, component_display_name='Brownian translational diffusion')
Create ComponentCollection components for the Brownian translational diffusion model at given Q values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Number, list, or np.ndarray
|
Scattering vector values. |
required |
component_display_name
|
str
|
Name of the Lorentzian component. |
'Brownian translational diffusion'
|
Returns:
| Type | Description |
|---|---|
List[ComponentCollection]
|
List[ComponentCollection]: List of ComponentCollections with Lorentzian components for each Q value. Each Lorentzian has a width given by \(D*Q^2\) and an area given by the scale parameter multiplied by the QISF (which is 1 for this model). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If component_display_name is not a string. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
diffusion_coefficient
property
writable
Get the diffusion coefficient parameter D.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
Diffusion coefficient D in m^2/s. |
ComponentCollection
Bases: ModelBase
Collection of model components representing a sample, background or resolution model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
Unit of the sample model. Defaults to "meV". |
'meV'
|
display_name
|
str
|
Display name of the sample model. |
'MyComponentCollection'
|
unique_name
|
str | None
|
Unique name of the sample model. If None, a unique_name is automatically generated. |
None
|
components
|
List[ModelComponent] | None
|
Initial model components to add to the ComponentCollection. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
components |
List[ModelComponent]
|
List of model components in the collection. |
unit |
str | Unit
|
Unit of the sample model. |
display_name |
str
|
Display name of the sample model. |
unique_name |
str
|
Unique name of the sample model. |
Source code in src/easydynamics/sample_model/component_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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
__contains__(item)
Check if a component with the given name or instance exists in the ComponentCollection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
str or ModelComponent
|
The component name or instance to check for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the component exists, False otherwise. |
Source code in src/easydynamics/sample_model/component_collection.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
__init__(unit='meV', display_name='MyComponentCollection', unique_name=None, components=None)
Initialize a new ComponentCollection.
unit (str | sc.Unit | None): Unit of the sample model. Defaults to "meV". display_name (str | None): Display name of the sample model. unique_name (str | None): Unique name of the sample model. Defaults to None. components (List[ModelComponent] | None): Initial model components to add to the ComponentCollection.
Raises:
| Type | Description |
|---|---|
TypeError
|
If unit is not a string or sc.Unit, or if components is not a list of ModelComponent. |
ValueError
|
If components contains duplicate unique names. |
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
__repr__()
Return a string representation of the ComponentCollection.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String representation of the ComponentCollection. |
Source code in src/easydynamics/sample_model/component_collection.py
441 442 443 444 445 446 447 448 449 | |
append_component(component)
Append a model component or the components from another ComponentCollection to this ComponentCollection.
component (ModelComponent | ComponentCollection): The component to append. If a ComponentCollection is provided, all of its components will be appended.
Raises:
| Type | Description |
|---|---|
TypeError
|
If component is not a ModelComponent or ComponentCollection. |
ValueError
|
If a component with the same unique name already exists in the collection. |
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
clear_components()
Remove all components.
Source code in src/easydynamics/sample_model/component_collection.py
301 302 303 | |
convert_unit(unit)
Convert the unit of the ComponentCollection and all its components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
The target unit to convert to. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If unit is not a string or sc.Unit. |
UnitError
|
If any component cannot be converted to the specified unit. |
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
evaluate(x)
Evaluate the sum of all components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Number, list, np.ndarray, sc.Variable, or sc.DataArray
|
Energy axis. |
required |
Returns np.ndarray: Evaluated model values.
Source code in src/easydynamics/sample_model/component_collection.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
evaluate_component(x, unique_name)
Evaluate a single component by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Number, list, np.ndarray, sc.Variable, or sc.DataArray
|
Energy axis. |
required |
unique_name
|
str
|
Component unique name. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Evaluated values for the specified component. |
Raises: ValueError: If there are no components in the model. TypeError: If unique_name is not a string. KeyError: If no component with the given unique name exists in the collection.
Source code in src/easydynamics/sample_model/component_collection.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
fix_all_parameters()
Fix all free parameters in the model.
Source code in src/easydynamics/sample_model/component_collection.py
406 407 408 409 | |
free_all_parameters()
Free all fixed parameters in the model.
Source code in src/easydynamics/sample_model/component_collection.py
411 412 413 414 | |
get_all_variables()
Get all parameters from the model component.
Returns:
| Type | Description |
|---|---|
list[DescriptorBase]
|
List[Parameter]: List of parameters in the component. |
Source code in src/easydynamics/sample_model/component_collection.py
344 345 346 347 348 349 350 351 | |
list_component_names()
List the names of all components in the model.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: List of unique names of the components in the |
List[str]
|
collection. |
Source code in src/easydynamics/sample_model/component_collection.py
291 292 293 294 295 296 297 298 299 | |
normalize_area()
Normalize the areas of all components so they sum to 1. This is useful for convolutions.
Raises:
| Type | Description |
|---|---|
ValueError
|
If there are no components in the model. |
ValueError
|
If the total area is zero or not finite, which would prevent normalization. |
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
remove_component(unique_name)
Remove a component from the collection by its unique name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unique_name
|
str
|
Unique name of the component to remove. |
required |
Raises: TypeError: If unique_name is not a string. KeyError: If no component with the given unique name exists in the collection.
Source code in src/easydynamics/sample_model/component_collection.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
unit
property
writable
Get the unit of the ComponentCollection.
Returns:
| Type | Description |
|---|---|
str | Unit | None
|
str | sc.Unit | None: The unit of the ComponentCollection, |
str | Unit | None
|
which is the same as the unit of its components. |
DampedHarmonicOscillator
Bases: CreateParametersMixin, ModelComponent
Model of a Damped Harmonic Oscillator (DHO).
The intensity is given by $$ I(x) = \frac{2 A x_0^2 \gamma}{\pi \left( (x^2 - x_0^2)^2 + (2 \gamma x)^2 \right)}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\gamma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Area under the curve. |
1.0
|
center
|
Int | float
|
Resonance frequency, approximately the peak position. |
1.0
|
width
|
Int | float
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'DampedHarmonicOscillator'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Area under the curve. |
center |
Parameter
|
Resonance frequency, approximately the peak position. |
width |
Parameter
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Display name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 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 | |
__init__(area=1.0, center=1.0, width=1.0, unit='meV', display_name='DampedHarmonicOscillator', unique_name=None)
Initialize the Damped Harmonic Oscillator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Area under the curve. |
1.0
|
center
|
Int | float
|
Resonance frequency, approximately the peak position. |
1.0
|
width
|
Int | float
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'DampedHarmonicOscillator'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are not numbers or Parameters. |
ValueError
|
If center or width are not positive. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 | |
__repr__()
Return a string representation of the Damped Harmonic Oscillator.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Damped Harmonic Oscillator. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
209 210 211 212 213 214 215 216 217 218 219 220 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Damped Harmonic Oscillator at the given x values.
If x is a scipp Variable, the unit of the DHO will be converted to match x. The intensity is given by $$ I(x) = \frac{2 A x_0^2 \gamma}{\pi \left( (x^2 - x_0^2)^2 + (2 \gamma x)^2 \right)}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\gamma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the DHO. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the DHO at the given x values. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 | |
width
property
writable
Get the width parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
DeltaFunction
Bases: CreateParametersMixin, ModelComponent
Delta function.
Evaluates to zero everywhere, except in convolutions, where it acts as an identity. This is handled by the Convolution method. If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Int | float | None
|
Center of the delta function. If None, defaults to 0 and is fixed. |
None
|
area
|
Int | float
|
Total area under the curve. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
center |
Parameter
|
Center of the delta function. |
area |
Parameter
|
Total area under the curve. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 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 | |
__init__(center=None, area=1.0, unit='meV', display_name='DeltaFunction', unique_name=None)
Initialize the Delta function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Int | float | None
|
Center of the delta function. If None, defaults to 0 and is fixed. |
None
|
area
|
Int | float
|
Total area under the curve. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If center is not a number or None. |
TypeError
|
If area is not a number. |
TypeError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
__repr__()
Return a string representation of the Delta function.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Delta function. |
Source code in src/easydynamics/sample_model/components/delta_function.py
184 185 186 187 188 189 190 191 192 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Delta function at the given x values.
The Delta function evaluates to zero everywhere, except at the center. Its numerical integral is equal to the area. It acts as an identity in convolutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the Delta function. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The evaluated Delta function at the given x values. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
Gaussian
Bases: CreateParametersMixin, ModelComponent
Model of a Gaussian function.
The intensity is given by
$$ I(x) = \frac{A}{\sigma \sqrt{2\pi}} \exp\left( -\frac{1}{2} \left(\frac{x - x_0}{\sigma}\right)^2 \right) $$
where \(A\) is the area, \(x_0\) is the center, and \(\sigma\) is the width.
If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Args: area (Int | float | Parameter | None): Area of the Gaussian. center (Int | float | Parameter | None): Center of the Gaussian. If None, defaults to 0 and is fixed. width (Int | float | Parameter | None): Standard deviation. unit (str | sc.Unit): Unit of the parameters. Defaults to "meV". display_name (str | None): Name of the component. unique_name (str | None): Unique name of the component. if None, a unique_name is automatically generated.
Attributes: area (Parameter): Area of the Gaussian. center (Parameter): Center of the Gaussian. width (Parameter): Standard deviation of the Gaussian. unit (str | sc.Unit): Unit of the parameters. display_name (str | None): Name of the component. unique_name (str | None): Unique name of the component.
Source code in src/easydynamics/sample_model/components/gaussian.py
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 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 | |
__init__(area=1.0, center=None, width=1.0, unit='meV', display_name='Gaussian', unique_name=None)
Initialize the Gaussian component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter | None
|
Area of the Gaussian. |
1.0
|
center
|
Int | float | Parameter | None
|
Center of the Gaussian. If None, defaults to 0 and is fixed. |
None
|
width
|
Int | float | Parameter | None
|
Standard deviation. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Gaussian'
|
unique_name
|
str | None
|
Unique name of the component. if None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If area, center, or width are not numbers or Parameters. |
ValueError
|
If width is not positive. |
TypeError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/gaussian.py
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 | |
__repr__()
Return a string representation of the Gaussian.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Gaussian. |
Source code in src/easydynamics/sample_model/components/gaussian.py
221 222 223 224 225 226 227 228 229 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Gaussian at the given x values.
If x is a scipp Variable, the unit of the Gaussian will be converted to match x. The intensity is given by $$ I(x) = \frac{A}{\sigma \sqrt{2\pi}} \exp\left( -\frac{1}{2} \left(\frac{x - x_0}{\sigma}\right)^2 \right) $$
where \(A\) is the area, \(x_0\) is the center, and \(\sigma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric or list or ndarray or Variable or DataArray
|
The x values at which to evaluate the Gaussian. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Gaussian at the given x values. |
Source code in src/easydynamics/sample_model/components/gaussian.py
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 | |
width
property
writable
Get the width parameter (standard deviation).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
InstrumentModel
Bases: NewBase
InstrumentModel represents a model of the instrument in an experiment at various Q. It can contain a model of the resolution function for convolutions, of the background and an offset in the energy axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str | None
|
The display name of the InstrumentModel. Default is "MyInstrumentModel". |
'MyInstrumentModel'
|
unique_name
|
str | None
|
The unique name of the InstrumentModel. Default is None. |
None
|
Q
|
ndarray | list | Variable | None
|
The Q values where the instrument is modelled. |
None
|
resolution_model
|
ResolutionModel | None
|
The resolution model of the instrument. If None, an empty resolution model is created and no resolution convolution is carried out. Default is None. |
None
|
background_model
|
BackgroundModel | None
|
The background model of the instrument. If None, an empty background model is created, and the background evaluates to 0. Default is None. |
None
|
energy_offset
|
float | int | None
|
Template energy offset of the instrument. Will be copied to each Q value. If None, the energy offset will be 0. Default is None. |
None
|
unit
|
str | Unit
|
The unit of the energy axis. Default is 'meV'. |
'meV'
|
Attributes:
| Name | Type | Description |
|---|---|---|
resolution_model |
ResolutionModel
|
The resolution model of the instrument. |
background_model |
BackgroundModel
|
The background model of the instrument. |
Q |
ndarray | None
|
The Q values where the instrument is modelled. |
energy_offset |
Parameter
|
The template energy offset Parameter of the instrument. Will be copied to each Q value. |
unit |
str | Unit
|
The unit of the energy axis. |
Source code in src/easydynamics/sample_model/instrument_model.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 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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
Q
property
writable
Get the Q values of the InstrumentModel.
Returns:
| Type | Description |
|---|---|
ndarray | None
|
np.ndarray or None: The Q values of the InstrumentModel, or None if not set |
__init__(display_name='MyInstrumentModel', unique_name=None, Q=None, resolution_model=None, background_model=None, energy_offset=None, unit='meV')
Initialize an InstrumentModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str | None
|
The display name of the InstrumentModel. Default is "MyInstrumentModel". |
'MyInstrumentModel'
|
unique_name
|
str | None
|
The unique name of the InstrumentModel. Default is None. |
None
|
Q
|
ndarray | list | Variable | None
|
The Q values where the instrument is modelled. |
None
|
resolution_model
|
ResolutionModel | None
|
The resolution model of the instrument. If None, an empty resolution model is created and no resolution convolution is carried out. Default is None. |
None
|
background_model
|
BackgroundModel | None
|
The background model of the instrument. If None, an empty background model is created, and the background evaluates to 0. Default is None. |
None
|
energy_offset
|
float | int | None
|
Template energy offset of the instrument. Will be copied to each Q value. If None, the energy offset will be 0. Default is None. |
None
|
unit
|
str | Unit
|
The unit of the energy axis. Default is 'meV'. |
'meV'
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If resolution_model is not a ResolutionModel or None |
TypeError
|
If background_model is not a BackgroundModel or None |
TypeError
|
If energy_offset is not a number or None |
UnitError
|
If unit is not a valid unit string or scipp Unit. |
Source code in src/easydynamics/sample_model/instrument_model.py
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 | |
__repr__()
Return a string representation of the InstrumentModel.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the InstrumentModel. |
Source code in src/easydynamics/sample_model/instrument_model.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
background_model
property
writable
Get the background model of the instrument.
Returns:
| Name | Type | Description |
|---|---|---|
BackgroundModel |
BackgroundModel
|
The background model of the instrument. |
convert_unit(unit_str)
Convert the unit of the InstrumentModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_str
|
str | Unit
|
The unit to convert to. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If unit_str is not a string or scipp Unit. |
ValueError
|
If unit_str is not a valid unit string or scipp Unit. |
Source code in src/easydynamics/sample_model/instrument_model.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
energy_offset
property
writable
Get the energy offset template parameter of the instrument model.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The energy offset template parameter of the instrument model. |
fix_resolution_parameters()
Fix all parameters in the resolution model.
Source code in src/easydynamics/sample_model/instrument_model.py
347 348 349 | |
free_resolution_parameters()
Free all parameters in the resolution model.
Source code in src/easydynamics/sample_model/instrument_model.py
351 352 353 | |
get_all_variables(Q_index=None)
Get all variables in the InstrumentModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int | None
|
The index of the Q value to get variables for. If None, get variables for all Q values. |
None
|
Returns:
| Type | Description |
|---|---|
list[Parameter]
|
list[Parameter]: A list of all variables in the InstrumentModel. If Q_index is specified, only variables from the ComponentCollection at the given Q index are included. Otherwise, all variables in the InstrumentModel are included. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If Q_index is not an int or None. |
IndexError
|
If Q_index is out of bounds for the Q values in the InstrumentModel. |
Source code in src/easydynamics/sample_model/instrument_model.py
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 | |
get_energy_offset_at_Q(Q_index)
Get the energy offset Parameter at a specific Q index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int
|
The index of the Q value to get the energy offset for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The energy offset Parameter at the specified Q index. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no Q values are set in the InstrumentModel. |
IndexError
|
If Q_index is out of bounds. |
Source code in src/easydynamics/sample_model/instrument_model.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
resolution_model
property
writable
Get the resolution model of the instrument.
Returns:
| Name | Type | Description |
|---|---|---|
ResolutionModel |
ResolutionModel
|
The resolution model of the instrument. |
unit
property
writable
Get the unit of the InstrumentModel.
Returns:
| Type | Description |
|---|---|
str | Unit
|
The unit of the InstrumentModel. |
Lorentzian
Bases: CreateParametersMixin, ModelComponent
Model of a Lorentzian function.
The intensity is given by $$ I(x) = \frac{A}{\pi} \frac{\Gamma}{(x - x_0)^2 + \Gamma^2}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\Gamma\) is the half width at half maximum (HWHM).
If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter
|
Area of the Lorentzian. |
1.0
|
center
|
Int | float | None | Parameter
|
Center of the Lorentzian. If None, defaults to 0 and is fixed |
None
|
width
|
Int | float | Parameter
|
Half width at half maximum (HWHM). |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Lorentzian'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Area of the Lorentzian. |
center |
Parameter
|
Center of the Lorentzian. |
width |
Parameter
|
Half width at half maximum (HWHM) of the Lorentzian. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 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 | |
__init__(area=1.0, center=None, width=1.0, unit='meV', display_name='Lorentzian', unique_name=None)
Initialize the Lorentzian component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter
|
Area of the Lorentzian. |
1.0
|
center
|
Int | float | None | Parameter
|
Center of the Lorentzian. If None, defaults to 0 and is fixed |
None
|
width
|
Int | float | Parameter
|
Half width at half maximum (HWHM). |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Lorentzian'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are of the wrong type. |
ValueError
|
If width is not positive. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 | |
__repr__()
Return a string representation of the Lorentzian.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Lorentzian. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
204 205 206 207 208 209 210 211 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Lorentzian at the given x values.
If x is a scipp Variable, the unit of the Lorentzian will be converted to match x. The intensity is given by
where \(A\) is the area, \(x_0\) is the center, and \(\Gamma\) is the half width at half maximum (HWHM).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric or list or ndarray or Variable or DataArray
|
The x values at which to evaluate the Lorentzian. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Lorentzian at the given x values. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 | |
width
property
writable
Get the width parameter (HWHM).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
Polynomial
Bases: ModelComponent
Polynomial function component.
The intensity is given by $$ I(x) = c_0 + c_1 x + c_2 x^2 + ... + c_N x^N, $$ where \(C_i\) are the coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coefficients
|
list or tuple
|
Coefficients c0, c1, ..., cN |
(0.0,)
|
unit
|
str or Unit
|
Unit of the Polynomial component. |
'meV'
|
display_name
|
str
|
Display name of the Polynomial component. |
'Polynomial'
|
unique_name
|
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
coefficients |
list of Parameter
|
Coefficients of the polynomial as Parameters. |
unit |
str
|
Unit of the Polynomial component. |
display_name |
str
|
Display name of the Polynomial component. |
unique_name |
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
Source code in src/easydynamics/sample_model/components/polynomial.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 | |
__init__(coefficients=(0.0,), unit='meV', display_name='Polynomial', unique_name=None)
Initialize the Polynomial component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coefficients
|
list or tuple
|
Coefficients c0, c1, ..., cN |
(0.0,)
|
unit
|
str or Unit
|
Unit of the Polynomial component. |
'meV'
|
display_name
|
str
|
Display name of the Polynomial component. |
'Polynomial'
|
unique_name
|
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If coefficients is not a sequence of numbers or Parameters. |
ValueError
|
If coefficients is an empty sequence. |
TypeError
|
If any item in coefficients is not a number or Parameter. |
UnitError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/polynomial.py
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 | |
__repr__()
Return a string representation of the Polynomial.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Polynomial. |
Source code in src/easydynamics/sample_model/components/polynomial.py
244 245 246 247 248 249 250 251 252 253 | |
coefficient_values()
Get the coefficients of the polynomial as a list.
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: The coefficient values of the polynomial. |
Source code in src/easydynamics/sample_model/components/polynomial.py
144 145 146 147 148 149 150 151 | |
coefficients
property
writable
Get the coefficients of the polynomial as a list of Parameters.
Returns:
| Type | Description |
|---|---|
list[Parameter]
|
list[Parameter]: The coefficients of the polynomial. |
convert_unit(unit)
Convert the unit of the polynomial.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str or Unit
|
The target unit to convert to. |
required |
Raises:
| Type | Description |
|---|---|
UnitError
|
If the provided unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/polynomial.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
degree
property
writable
Get the degree of the polynomial.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The degree of the polynomial. |
evaluate(x)
Evaluate the Polynomial at the given x values.
The intensity is given by $$ I(x) = c_0 + c_1 x + c_2 x^2 + ... + c_N x^N, $$ where \(C_i\) are the coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the Polynomial. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The evaluated Polynomial at the given x values. |
Source code in src/easydynamics/sample_model/components/polynomial.py
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 | |
get_all_variables()
Get all parameters from the model component.
Returns: List[Parameter]: List of parameters in the component.
Source code in src/easydynamics/sample_model/components/polynomial.py
211 212 213 214 215 216 217 | |
ResolutionModel
Bases: ModelBase
ResolutionModel represents a model of the instrment resolution in an experiment at various Q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyResolutionModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
Q_type | None
|
Q values for the model. If None, Q is not set. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the model. |
components |
list[ModelComponent]
|
List of ModelComponents in the model. |
Q |
ndarray | Numeric | list | ArrayLike | Variable | None
|
Q values of the model. |
Source code in src/easydynamics/sample_model/resolution_model.py
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 | |
__init__(display_name='MyResolutionModel', unique_name=None, unit='meV', components=None, Q=None)
Initialize a ResolutionModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyResolutionModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
Q_type | None
|
Q values for the model. If None, Q is not set. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If components is not a ModelComponent or ComponentCollection. |
ValueError
|
If Q is not a valid Q_type. |
Source code in src/easydynamics/sample_model/resolution_model.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 | |
append_component(component)
Append a component to the ResolutionModel.
Does not allow DeltaFunction or Polynomial components, as these are not physical resolution components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ModelComponent | ComponentCollection
|
Component(s) to append. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the component is a DeltaFunction or Polynomial |
Source code in src/easydynamics/sample_model/resolution_model.py
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 | |
SampleModel
Bases: ModelBase
SampleModel represents a model of a sample with components and diffusion models, parameterized by Q and optionally temperature. Generates ComponentCollections for each Q value, combining components from the base model and diffusion models.
Applies detailed balancing based on temperature if provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MySampleModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. If None, defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
(Number, list, ndarray, array | None)
|
Q values for the model. If None, Q is not set. |
None
|
diffusion_models
|
DiffusionModelBase | list[DiffusionModelBase] | None
|
Diffusion models to include in the SampleModel. If None, no diffusion models are added. |
None
|
temperature
|
float | None
|
Temperature for detailed balancing. If None, no detailed balancing is applied. |
None
|
temperature_unit
|
str | Unit
|
Unit of the temperature. Defaults to "K". |
'K'
|
divide_by_temperature
|
bool
|
Whether to divide the detailed balance factor by temperature. Defaults to True. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the model. |
components |
list[ModelComponent]
|
List of ModelComponents in the model. |
Q |
ndarray | Numeric | list | ArrayLike | Variable | None
|
Q values of the model. |
diffusion_models |
list[DiffusionModelBase]
|
List of diffusion models in the SampleModel. |
temperature |
Parameter | None
|
Temperature Parameter for detailed balancing, or None if not set. |
divide_by_temperature |
bool
|
Whether to divide the detailed balance factor by temperature. |
Source code in src/easydynamics/sample_model/sample_model.py
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 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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
__init__(display_name='MySampleModel', unique_name=None, unit='meV', components=None, Q=None, diffusion_models=None, temperature=None, temperature_unit='K', divide_by_temperature=True)
Initialize the SampleModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MySampleModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. If None, defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
(Number, list, ndarray, array | None)
|
Q values for the model. If None, Q is not set. |
None
|
diffusion_models
|
DiffusionModelBase | list[DiffusionModelBase] | None
|
Diffusion models to include in the SampleModel. If None, no diffusion models are added. |
None
|
temperature
|
float | None
|
Temperature for detailed balancing. If None, no detailed balancing is applied. |
None
|
temperature_unit
|
str | Unit
|
Unit of the temperature. Defaults to "K". |
'K'
|
divide_by_temperature
|
bool
|
Whether to divide the detailed balance factor by temperature. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If diffusion_models is not a DiffusionModelBase, a list of DiffusionModelBase, or None. |
TypeError
|
If temperature is not a number or None. |
ValueError
|
If temperature is negative. |
TypeError
|
If divide_by_temperature is not a bool. |
Source code in src/easydynamics/sample_model/sample_model.py
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 | |
__repr__()
Return a string representation of the SampleModel.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the SampleModel. |
Source code in src/easydynamics/sample_model/sample_model.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
append_diffusion_model(diffusion_model)
Append a DiffusionModel to the SampleModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diffusion_model
|
DiffusionModelBase
|
The DiffusionModel to append. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the diffusion_model is not a DiffusionModelBase |
Source code in src/easydynamics/sample_model/sample_model.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
clear_diffusion_models()
Clear all DiffusionModels from the SampleModel.
Source code in src/easydynamics/sample_model/sample_model.py
192 193 194 195 | |
convert_temperature_unit(unit)
Convert the unit of the temperature Parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
The unit to convert the temperature Parameter to. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If temperature is not set or conversion fails. |
Source code in src/easydynamics/sample_model/sample_model.py
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 | |
diffusion_models
property
writable
Get the diffusion models of the SampleModel.
Returns:
| Type | Description |
|---|---|
list[DiffusionModelBase]
|
list[DiffusionModelBase]: The diffusion models of the SampleModel. |
divide_by_temperature
property
writable
Get whether to divide the detailed balance factor by temperature.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the detailed balance factor is divided by temperature, False otherwise. |
evaluate(x)
Evaluate the sample model at all Q for the given x values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values to evaluate the model at. Can be a number, list, numpy array, scipp Variable, or scipp DataArray. |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
list[np.ndarray]: List of evaluated model values for each Q. |
Source code in src/easydynamics/sample_model/sample_model.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
get_all_variables(Q_index=None)
Get all Parameters and Descriptors from all ComponentCollections in the SampleModel.
Also includes temperature if set and all variables from diffusion models. Ignores the Parameters and Descriptors in self._components as these are just templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int | None
|
If specified, only get variables from the ComponentCollection at the given Q index. If None, get variables from all ComponentCollections. |
None
|
Source code in src/easydynamics/sample_model/sample_model.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
remove_diffusion_model(name)
Remove a DiffusionModel from the SampleModel by unique name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The unique name of the DiffusionModel to remove. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no DiffusionModel with the given unique name is found. |
Source code in src/easydynamics/sample_model/sample_model.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
temperature
property
writable
Get the temperature of the SampleModel.
Returns:
| Type | Description |
|---|---|
Parameter | None
|
Parameter | None: The temperature Parameter of the SampleModel, or None if not set. |
temperature_unit
property
writable
Get the temperature unit of the SampleModel.
Returns:
| Type | Description |
|---|---|
str | Unit
|
str | sc.Unit: The unit of the temperature Parameter. |
Voigt
Bases: CreateParametersMixin, ModelComponent
Voigt profile, a convolution of Gaussian and Lorentzian. If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Use scipy.special.voigt_profile to evaluate the Voigt profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Total area under the curve. |
1.0
|
center
|
Int | float | None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int | float
|
Standard deviation of the Gaussian part. |
1.0
|
lorentzian_width
|
Int | float
|
Half width at half max (HWHM) of the Lorentzian part. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'Voigt'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Total area under the curve. |
center |
Parameter
|
Center of the Voigt profile. |
gaussian_width |
Parameter
|
Standard deviation of the Gaussian part. |
lorentzian_width |
Parameter
|
Half width at half max (HWHM) of the Lorentzian part. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Display name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/voigt.py
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 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 | |
__init__(area=1.0, center=None, gaussian_width=1.0, lorentzian_width=1.0, unit='meV', display_name='Voigt', unique_name=None)
Initialize a Voigt component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Total area under the curve. |
1.0
|
center
|
Int | float | None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int | float
|
Standard deviation of the Gaussian part. |
1.0
|
lorentzian_width
|
Int | float
|
Half width at half max (HWHM) of the Lorentzian part. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'Voigt'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are not of the correct type. |
ValueError
|
If any of the parameters are not valid (e.g. negative widths). |
Source code in src/easydynamics/sample_model/components/voigt.py
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 | |
__repr__()
Return a string representation of the Voigt.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Voigt. |
Source code in src/easydynamics/sample_model/components/voigt.py
240 241 242 243 244 245 246 247 248 249 250 251 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Voigt at the given x values.
If x is a scipp Variable, the unit of the Voigt will be converted to match x. The Voigt evaluates to the convolution of a Gaussian with sigma gaussian_width and a Lorentzian with half width at half max lorentzian_width, centered at center, with area equal to area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list[Numeric] | ndarray | Variable | DataArray
|
The x values at which to evaluate the Voigt. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Voigt at the given x values. |
Source code in src/easydynamics/sample_model/components/voigt.py
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 | |
gaussian_width
property
writable
Get the Gaussian width parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The Gaussian width parameter. |
lorentzian_width
property
writable
Get the Lorentzian width parameter (HWHM).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The Lorentzian width parameter. |
background_model
BackgroundModel
Bases: ModelBase
BackgroundModel represents a model of the background in an experiment at various Q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyBackgroundModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
Q_type | None
|
Q values for the model. If None, Q is not set. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the model. |
components |
list[ModelComponent]
|
List of ModelComponents in the model. |
Q |
ndarray | Numeric | list | ArrayLike | Variable | None
|
Q values of the model. |
Source code in src/easydynamics/sample_model/background_model.py
13 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 | |
__init__(display_name='MyBackgroundModel', unique_name=None, unit='meV', components=None, Q=None)
Initialize the BackgroundModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyBackgroundModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
Q_type | None
|
Q values for the model. If None, Q is not set. |
None
|
Source code in src/easydynamics/sample_model/background_model.py
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 | |
component_collection
ComponentCollection
Bases: ModelBase
Collection of model components representing a sample, background or resolution model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
Unit of the sample model. Defaults to "meV". |
'meV'
|
display_name
|
str
|
Display name of the sample model. |
'MyComponentCollection'
|
unique_name
|
str | None
|
Unique name of the sample model. If None, a unique_name is automatically generated. |
None
|
components
|
List[ModelComponent] | None
|
Initial model components to add to the ComponentCollection. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
components |
List[ModelComponent]
|
List of model components in the collection. |
unit |
str | Unit
|
Unit of the sample model. |
display_name |
str
|
Display name of the sample model. |
unique_name |
str
|
Unique name of the sample model. |
Source code in src/easydynamics/sample_model/component_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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
__contains__(item)
Check if a component with the given name or instance exists in the ComponentCollection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
str or ModelComponent
|
The component name or instance to check for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the component exists, False otherwise. |
Source code in src/easydynamics/sample_model/component_collection.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
__init__(unit='meV', display_name='MyComponentCollection', unique_name=None, components=None)
Initialize a new ComponentCollection.
unit (str | sc.Unit | None): Unit of the sample model. Defaults to "meV". display_name (str | None): Display name of the sample model. unique_name (str | None): Unique name of the sample model. Defaults to None. components (List[ModelComponent] | None): Initial model components to add to the ComponentCollection.
Raises:
| Type | Description |
|---|---|
TypeError
|
If unit is not a string or sc.Unit, or if components is not a list of ModelComponent. |
ValueError
|
If components contains duplicate unique names. |
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
__repr__()
Return a string representation of the ComponentCollection.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String representation of the ComponentCollection. |
Source code in src/easydynamics/sample_model/component_collection.py
441 442 443 444 445 446 447 448 449 | |
append_component(component)
Append a model component or the components from another ComponentCollection to this ComponentCollection.
component (ModelComponent | ComponentCollection): The component to append. If a ComponentCollection is provided, all of its components will be appended.
Raises:
| Type | Description |
|---|---|
TypeError
|
If component is not a ModelComponent or ComponentCollection. |
ValueError
|
If a component with the same unique name already exists in the collection. |
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
clear_components()
Remove all components.
Source code in src/easydynamics/sample_model/component_collection.py
301 302 303 | |
convert_unit(unit)
Convert the unit of the ComponentCollection and all its components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
The target unit to convert to. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If unit is not a string or sc.Unit. |
UnitError
|
If any component cannot be converted to the specified unit. |
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
evaluate(x)
Evaluate the sum of all components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Number, list, np.ndarray, sc.Variable, or sc.DataArray
|
Energy axis. |
required |
Returns np.ndarray: Evaluated model values.
Source code in src/easydynamics/sample_model/component_collection.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
evaluate_component(x, unique_name)
Evaluate a single component by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Number, list, np.ndarray, sc.Variable, or sc.DataArray
|
Energy axis. |
required |
unique_name
|
str
|
Component unique name. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Evaluated values for the specified component. |
Raises: ValueError: If there are no components in the model. TypeError: If unique_name is not a string. KeyError: If no component with the given unique name exists in the collection.
Source code in src/easydynamics/sample_model/component_collection.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
fix_all_parameters()
Fix all free parameters in the model.
Source code in src/easydynamics/sample_model/component_collection.py
406 407 408 409 | |
free_all_parameters()
Free all fixed parameters in the model.
Source code in src/easydynamics/sample_model/component_collection.py
411 412 413 414 | |
get_all_variables()
Get all parameters from the model component.
Returns:
| Type | Description |
|---|---|
list[DescriptorBase]
|
List[Parameter]: List of parameters in the component. |
Source code in src/easydynamics/sample_model/component_collection.py
344 345 346 347 348 349 350 351 | |
list_component_names()
List the names of all components in the model.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: List of unique names of the components in the |
List[str]
|
collection. |
Source code in src/easydynamics/sample_model/component_collection.py
291 292 293 294 295 296 297 298 299 | |
normalize_area()
Normalize the areas of all components so they sum to 1. This is useful for convolutions.
Raises:
| Type | Description |
|---|---|
ValueError
|
If there are no components in the model. |
ValueError
|
If the total area is zero or not finite, which would prevent normalization. |
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
remove_component(unique_name)
Remove a component from the collection by its unique name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unique_name
|
str
|
Unique name of the component to remove. |
required |
Raises: TypeError: If unique_name is not a string. KeyError: If no component with the given unique name exists in the collection.
Source code in src/easydynamics/sample_model/component_collection.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
unit
property
writable
Get the unit of the ComponentCollection.
Returns:
| Type | Description |
|---|---|
str | Unit | None
|
str | sc.Unit | None: The unit of the ComponentCollection, |
str | Unit | None
|
which is the same as the unit of its components. |
components
DampedHarmonicOscillator
Bases: CreateParametersMixin, ModelComponent
Model of a Damped Harmonic Oscillator (DHO).
The intensity is given by $$ I(x) = \frac{2 A x_0^2 \gamma}{\pi \left( (x^2 - x_0^2)^2 + (2 \gamma x)^2 \right)}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\gamma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Area under the curve. |
1.0
|
center
|
Int | float
|
Resonance frequency, approximately the peak position. |
1.0
|
width
|
Int | float
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'DampedHarmonicOscillator'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Area under the curve. |
center |
Parameter
|
Resonance frequency, approximately the peak position. |
width |
Parameter
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Display name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 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 | |
__init__(area=1.0, center=1.0, width=1.0, unit='meV', display_name='DampedHarmonicOscillator', unique_name=None)
Initialize the Damped Harmonic Oscillator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Area under the curve. |
1.0
|
center
|
Int | float
|
Resonance frequency, approximately the peak position. |
1.0
|
width
|
Int | float
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'DampedHarmonicOscillator'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are not numbers or Parameters. |
ValueError
|
If center or width are not positive. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 | |
__repr__()
Return a string representation of the Damped Harmonic Oscillator.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Damped Harmonic Oscillator. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
209 210 211 212 213 214 215 216 217 218 219 220 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Damped Harmonic Oscillator at the given x values.
If x is a scipp Variable, the unit of the DHO will be converted to match x. The intensity is given by $$ I(x) = \frac{2 A x_0^2 \gamma}{\pi \left( (x^2 - x_0^2)^2 + (2 \gamma x)^2 \right)}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\gamma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the DHO. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the DHO at the given x values. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 | |
width
property
writable
Get the width parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
DeltaFunction
Bases: CreateParametersMixin, ModelComponent
Delta function.
Evaluates to zero everywhere, except in convolutions, where it acts as an identity. This is handled by the Convolution method. If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Int | float | None
|
Center of the delta function. If None, defaults to 0 and is fixed. |
None
|
area
|
Int | float
|
Total area under the curve. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
center |
Parameter
|
Center of the delta function. |
area |
Parameter
|
Total area under the curve. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 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 | |
__init__(center=None, area=1.0, unit='meV', display_name='DeltaFunction', unique_name=None)
Initialize the Delta function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Int | float | None
|
Center of the delta function. If None, defaults to 0 and is fixed. |
None
|
area
|
Int | float
|
Total area under the curve. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If center is not a number or None. |
TypeError
|
If area is not a number. |
TypeError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
__repr__()
Return a string representation of the Delta function.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Delta function. |
Source code in src/easydynamics/sample_model/components/delta_function.py
184 185 186 187 188 189 190 191 192 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Delta function at the given x values.
The Delta function evaluates to zero everywhere, except at the center. Its numerical integral is equal to the area. It acts as an identity in convolutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the Delta function. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The evaluated Delta function at the given x values. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
Gaussian
Bases: CreateParametersMixin, ModelComponent
Model of a Gaussian function.
The intensity is given by
$$ I(x) = \frac{A}{\sigma \sqrt{2\pi}} \exp\left( -\frac{1}{2} \left(\frac{x - x_0}{\sigma}\right)^2 \right) $$
where \(A\) is the area, \(x_0\) is the center, and \(\sigma\) is the width.
If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Args: area (Int | float | Parameter | None): Area of the Gaussian. center (Int | float | Parameter | None): Center of the Gaussian. If None, defaults to 0 and is fixed. width (Int | float | Parameter | None): Standard deviation. unit (str | sc.Unit): Unit of the parameters. Defaults to "meV". display_name (str | None): Name of the component. unique_name (str | None): Unique name of the component. if None, a unique_name is automatically generated.
Attributes: area (Parameter): Area of the Gaussian. center (Parameter): Center of the Gaussian. width (Parameter): Standard deviation of the Gaussian. unit (str | sc.Unit): Unit of the parameters. display_name (str | None): Name of the component. unique_name (str | None): Unique name of the component.
Source code in src/easydynamics/sample_model/components/gaussian.py
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 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 | |
__init__(area=1.0, center=None, width=1.0, unit='meV', display_name='Gaussian', unique_name=None)
Initialize the Gaussian component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter | None
|
Area of the Gaussian. |
1.0
|
center
|
Int | float | Parameter | None
|
Center of the Gaussian. If None, defaults to 0 and is fixed. |
None
|
width
|
Int | float | Parameter | None
|
Standard deviation. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Gaussian'
|
unique_name
|
str | None
|
Unique name of the component. if None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If area, center, or width are not numbers or Parameters. |
ValueError
|
If width is not positive. |
TypeError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/gaussian.py
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 | |
__repr__()
Return a string representation of the Gaussian.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Gaussian. |
Source code in src/easydynamics/sample_model/components/gaussian.py
221 222 223 224 225 226 227 228 229 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Gaussian at the given x values.
If x is a scipp Variable, the unit of the Gaussian will be converted to match x. The intensity is given by $$ I(x) = \frac{A}{\sigma \sqrt{2\pi}} \exp\left( -\frac{1}{2} \left(\frac{x - x_0}{\sigma}\right)^2 \right) $$
where \(A\) is the area, \(x_0\) is the center, and \(\sigma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric or list or ndarray or Variable or DataArray
|
The x values at which to evaluate the Gaussian. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Gaussian at the given x values. |
Source code in src/easydynamics/sample_model/components/gaussian.py
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 | |
width
property
writable
Get the width parameter (standard deviation).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
Lorentzian
Bases: CreateParametersMixin, ModelComponent
Model of a Lorentzian function.
The intensity is given by $$ I(x) = \frac{A}{\pi} \frac{\Gamma}{(x - x_0)^2 + \Gamma^2}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\Gamma\) is the half width at half maximum (HWHM).
If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter
|
Area of the Lorentzian. |
1.0
|
center
|
Int | float | None | Parameter
|
Center of the Lorentzian. If None, defaults to 0 and is fixed |
None
|
width
|
Int | float | Parameter
|
Half width at half maximum (HWHM). |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Lorentzian'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Area of the Lorentzian. |
center |
Parameter
|
Center of the Lorentzian. |
width |
Parameter
|
Half width at half maximum (HWHM) of the Lorentzian. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 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 | |
__init__(area=1.0, center=None, width=1.0, unit='meV', display_name='Lorentzian', unique_name=None)
Initialize the Lorentzian component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter
|
Area of the Lorentzian. |
1.0
|
center
|
Int | float | None | Parameter
|
Center of the Lorentzian. If None, defaults to 0 and is fixed |
None
|
width
|
Int | float | Parameter
|
Half width at half maximum (HWHM). |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Lorentzian'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are of the wrong type. |
ValueError
|
If width is not positive. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 | |
__repr__()
Return a string representation of the Lorentzian.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Lorentzian. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
204 205 206 207 208 209 210 211 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Lorentzian at the given x values.
If x is a scipp Variable, the unit of the Lorentzian will be converted to match x. The intensity is given by
where \(A\) is the area, \(x_0\) is the center, and \(\Gamma\) is the half width at half maximum (HWHM).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric or list or ndarray or Variable or DataArray
|
The x values at which to evaluate the Lorentzian. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Lorentzian at the given x values. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 | |
width
property
writable
Get the width parameter (HWHM).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
Polynomial
Bases: ModelComponent
Polynomial function component.
The intensity is given by $$ I(x) = c_0 + c_1 x + c_2 x^2 + ... + c_N x^N, $$ where \(C_i\) are the coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coefficients
|
list or tuple
|
Coefficients c0, c1, ..., cN |
(0.0,)
|
unit
|
str or Unit
|
Unit of the Polynomial component. |
'meV'
|
display_name
|
str
|
Display name of the Polynomial component. |
'Polynomial'
|
unique_name
|
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
coefficients |
list of Parameter
|
Coefficients of the polynomial as Parameters. |
unit |
str
|
Unit of the Polynomial component. |
display_name |
str
|
Display name of the Polynomial component. |
unique_name |
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
Source code in src/easydynamics/sample_model/components/polynomial.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 | |
__init__(coefficients=(0.0,), unit='meV', display_name='Polynomial', unique_name=None)
Initialize the Polynomial component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coefficients
|
list or tuple
|
Coefficients c0, c1, ..., cN |
(0.0,)
|
unit
|
str or Unit
|
Unit of the Polynomial component. |
'meV'
|
display_name
|
str
|
Display name of the Polynomial component. |
'Polynomial'
|
unique_name
|
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If coefficients is not a sequence of numbers or Parameters. |
ValueError
|
If coefficients is an empty sequence. |
TypeError
|
If any item in coefficients is not a number or Parameter. |
UnitError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/polynomial.py
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 | |
__repr__()
Return a string representation of the Polynomial.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Polynomial. |
Source code in src/easydynamics/sample_model/components/polynomial.py
244 245 246 247 248 249 250 251 252 253 | |
coefficient_values()
Get the coefficients of the polynomial as a list.
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: The coefficient values of the polynomial. |
Source code in src/easydynamics/sample_model/components/polynomial.py
144 145 146 147 148 149 150 151 | |
coefficients
property
writable
Get the coefficients of the polynomial as a list of Parameters.
Returns:
| Type | Description |
|---|---|
list[Parameter]
|
list[Parameter]: The coefficients of the polynomial. |
convert_unit(unit)
Convert the unit of the polynomial.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str or Unit
|
The target unit to convert to. |
required |
Raises:
| Type | Description |
|---|---|
UnitError
|
If the provided unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/polynomial.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
degree
property
writable
Get the degree of the polynomial.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The degree of the polynomial. |
evaluate(x)
Evaluate the Polynomial at the given x values.
The intensity is given by $$ I(x) = c_0 + c_1 x + c_2 x^2 + ... + c_N x^N, $$ where \(C_i\) are the coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the Polynomial. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The evaluated Polynomial at the given x values. |
Source code in src/easydynamics/sample_model/components/polynomial.py
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 | |
get_all_variables()
Get all parameters from the model component.
Returns: List[Parameter]: List of parameters in the component.
Source code in src/easydynamics/sample_model/components/polynomial.py
211 212 213 214 215 216 217 | |
Voigt
Bases: CreateParametersMixin, ModelComponent
Voigt profile, a convolution of Gaussian and Lorentzian. If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Use scipy.special.voigt_profile to evaluate the Voigt profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Total area under the curve. |
1.0
|
center
|
Int | float | None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int | float
|
Standard deviation of the Gaussian part. |
1.0
|
lorentzian_width
|
Int | float
|
Half width at half max (HWHM) of the Lorentzian part. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'Voigt'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Total area under the curve. |
center |
Parameter
|
Center of the Voigt profile. |
gaussian_width |
Parameter
|
Standard deviation of the Gaussian part. |
lorentzian_width |
Parameter
|
Half width at half max (HWHM) of the Lorentzian part. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Display name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/voigt.py
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 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 | |
__init__(area=1.0, center=None, gaussian_width=1.0, lorentzian_width=1.0, unit='meV', display_name='Voigt', unique_name=None)
Initialize a Voigt component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Total area under the curve. |
1.0
|
center
|
Int | float | None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int | float
|
Standard deviation of the Gaussian part. |
1.0
|
lorentzian_width
|
Int | float
|
Half width at half max (HWHM) of the Lorentzian part. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'Voigt'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are not of the correct type. |
ValueError
|
If any of the parameters are not valid (e.g. negative widths). |
Source code in src/easydynamics/sample_model/components/voigt.py
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 | |
__repr__()
Return a string representation of the Voigt.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Voigt. |
Source code in src/easydynamics/sample_model/components/voigt.py
240 241 242 243 244 245 246 247 248 249 250 251 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Voigt at the given x values.
If x is a scipp Variable, the unit of the Voigt will be converted to match x. The Voigt evaluates to the convolution of a Gaussian with sigma gaussian_width and a Lorentzian with half width at half max lorentzian_width, centered at center, with area equal to area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list[Numeric] | ndarray | Variable | DataArray
|
The x values at which to evaluate the Voigt. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Voigt at the given x values. |
Source code in src/easydynamics/sample_model/components/voigt.py
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 | |
gaussian_width
property
writable
Get the Gaussian width parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The Gaussian width parameter. |
lorentzian_width
property
writable
Get the Lorentzian width parameter (HWHM).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The Lorentzian width parameter. |
damped_harmonic_oscillator
DampedHarmonicOscillator
Bases: CreateParametersMixin, ModelComponent
Model of a Damped Harmonic Oscillator (DHO).
The intensity is given by $$ I(x) = \frac{2 A x_0^2 \gamma}{\pi \left( (x^2 - x_0^2)^2 + (2 \gamma x)^2 \right)}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\gamma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Area under the curve. |
1.0
|
center
|
Int | float
|
Resonance frequency, approximately the peak position. |
1.0
|
width
|
Int | float
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'DampedHarmonicOscillator'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Area under the curve. |
center |
Parameter
|
Resonance frequency, approximately the peak position. |
width |
Parameter
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Display name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 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 | |
__init__(area=1.0, center=1.0, width=1.0, unit='meV', display_name='DampedHarmonicOscillator', unique_name=None)
Initialize the Damped Harmonic Oscillator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Area under the curve. |
1.0
|
center
|
Int | float
|
Resonance frequency, approximately the peak position. |
1.0
|
width
|
Int | float
|
Damping constant, approximately the half width at half max (HWHM) of the peaks. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'DampedHarmonicOscillator'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are not numbers or Parameters. |
ValueError
|
If center or width are not positive. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 | |
__repr__()
Return a string representation of the Damped Harmonic Oscillator.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Damped Harmonic Oscillator. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
209 210 211 212 213 214 215 216 217 218 219 220 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Damped Harmonic Oscillator at the given x values.
If x is a scipp Variable, the unit of the DHO will be converted to match x. The intensity is given by $$ I(x) = \frac{2 A x_0^2 \gamma}{\pi \left( (x^2 - x_0^2)^2 + (2 \gamma x)^2 \right)}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\gamma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the DHO. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the DHO at the given x values. |
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
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 | |
width
property
writable
Get the width parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
delta_function
DeltaFunction
Bases: CreateParametersMixin, ModelComponent
Delta function.
Evaluates to zero everywhere, except in convolutions, where it acts as an identity. This is handled by the Convolution method. If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Int | float | None
|
Center of the delta function. If None, defaults to 0 and is fixed. |
None
|
area
|
Int | float
|
Total area under the curve. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
center |
Parameter
|
Center of the delta function. |
area |
Parameter
|
Total area under the curve. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 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 | |
__init__(center=None, area=1.0, unit='meV', display_name='DeltaFunction', unique_name=None)
Initialize the Delta function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Int | float | None
|
Center of the delta function. If None, defaults to 0 and is fixed. |
None
|
area
|
Int | float
|
Total area under the curve. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If center is not a number or None. |
TypeError
|
If area is not a number. |
TypeError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
__repr__()
Return a string representation of the Delta function.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Delta function. |
Source code in src/easydynamics/sample_model/components/delta_function.py
184 185 186 187 188 189 190 191 192 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Delta function at the given x values.
The Delta function evaluates to zero everywhere, except at the center. Its numerical integral is equal to the area. It acts as an identity in convolutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the Delta function. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The evaluated Delta function at the given x values. |
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
gaussian
Gaussian
Bases: CreateParametersMixin, ModelComponent
Model of a Gaussian function.
The intensity is given by
$$ I(x) = \frac{A}{\sigma \sqrt{2\pi}} \exp\left( -\frac{1}{2} \left(\frac{x - x_0}{\sigma}\right)^2 \right) $$
where \(A\) is the area, \(x_0\) is the center, and \(\sigma\) is the width.
If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Args: area (Int | float | Parameter | None): Area of the Gaussian. center (Int | float | Parameter | None): Center of the Gaussian. If None, defaults to 0 and is fixed. width (Int | float | Parameter | None): Standard deviation. unit (str | sc.Unit): Unit of the parameters. Defaults to "meV". display_name (str | None): Name of the component. unique_name (str | None): Unique name of the component. if None, a unique_name is automatically generated.
Attributes: area (Parameter): Area of the Gaussian. center (Parameter): Center of the Gaussian. width (Parameter): Standard deviation of the Gaussian. unit (str | sc.Unit): Unit of the parameters. display_name (str | None): Name of the component. unique_name (str | None): Unique name of the component.
Source code in src/easydynamics/sample_model/components/gaussian.py
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 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 | |
__init__(area=1.0, center=None, width=1.0, unit='meV', display_name='Gaussian', unique_name=None)
Initialize the Gaussian component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter | None
|
Area of the Gaussian. |
1.0
|
center
|
Int | float | Parameter | None
|
Center of the Gaussian. If None, defaults to 0 and is fixed. |
None
|
width
|
Int | float | Parameter | None
|
Standard deviation. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Gaussian'
|
unique_name
|
str | None
|
Unique name of the component. if None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If area, center, or width are not numbers or Parameters. |
ValueError
|
If width is not positive. |
TypeError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/gaussian.py
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 | |
__repr__()
Return a string representation of the Gaussian.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Gaussian. |
Source code in src/easydynamics/sample_model/components/gaussian.py
221 222 223 224 225 226 227 228 229 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Gaussian at the given x values.
If x is a scipp Variable, the unit of the Gaussian will be converted to match x. The intensity is given by $$ I(x) = \frac{A}{\sigma \sqrt{2\pi}} \exp\left( -\frac{1}{2} \left(\frac{x - x_0}{\sigma}\right)^2 \right) $$
where \(A\) is the area, \(x_0\) is the center, and \(\sigma\) is the width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric or list or ndarray or Variable or DataArray
|
The x values at which to evaluate the Gaussian. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Gaussian at the given x values. |
Source code in src/easydynamics/sample_model/components/gaussian.py
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 | |
width
property
writable
Get the width parameter (standard deviation).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
lorentzian
Lorentzian
Bases: CreateParametersMixin, ModelComponent
Model of a Lorentzian function.
The intensity is given by $$ I(x) = \frac{A}{\pi} \frac{\Gamma}{(x - x_0)^2 + \Gamma^2}, $$ where \(A\) is the area, \(x_0\) is the center, and \(\Gamma\) is the half width at half maximum (HWHM).
If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter
|
Area of the Lorentzian. |
1.0
|
center
|
Int | float | None | Parameter
|
Center of the Lorentzian. If None, defaults to 0 and is fixed |
None
|
width
|
Int | float | Parameter
|
Half width at half maximum (HWHM). |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Lorentzian'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Area of the Lorentzian. |
center |
Parameter
|
Center of the Lorentzian. |
width |
Parameter
|
Half width at half maximum (HWHM) of the Lorentzian. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 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 | |
__init__(area=1.0, center=None, width=1.0, unit='meV', display_name='Lorentzian', unique_name=None)
Initialize the Lorentzian component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float | Parameter
|
Area of the Lorentzian. |
1.0
|
center
|
Int | float | None | Parameter
|
Center of the Lorentzian. If None, defaults to 0 and is fixed |
None
|
width
|
Int | float | Parameter
|
Half width at half maximum (HWHM). |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV". |
'meV'
|
display_name
|
str | None
|
Name of the component. |
'Lorentzian'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are of the wrong type. |
ValueError
|
If width is not positive. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 | |
__repr__()
Return a string representation of the Lorentzian.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Lorentzian. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
204 205 206 207 208 209 210 211 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Lorentzian at the given x values.
If x is a scipp Variable, the unit of the Lorentzian will be converted to match x. The intensity is given by
where \(A\) is the area, \(x_0\) is the center, and \(\Gamma\) is the half width at half maximum (HWHM).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric or list or ndarray or Variable or DataArray
|
The x values at which to evaluate the Lorentzian. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Lorentzian at the given x values. |
Source code in src/easydynamics/sample_model/components/lorentzian.py
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 | |
width
property
writable
Get the width parameter (HWHM).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The width parameter. |
mixins
CreateParametersMixin
Provides parameter creation and validation methods for model components.
This mixin provides methods to create and validate common physics parameters (area, center, width) with appropriate bounds and type checking.
Source code in src/easydynamics/sample_model/components/mixins.py
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 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 | |
model_component
ModelComponent
Bases: ModelBase
Abstract base class for all model components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
The unit of the model component. Default is 'meV'. |
'meV'
|
display_name
|
str | None
|
A human-readable name for the component. Default is None. |
None
|
unique_name
|
str | None
|
A unique identifier for the component. Default is None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str
|
The unit of the model component. |
display_name |
str | None
|
A human-readable name for the component. |
unique_name |
str | None
|
A unique identifier for the component. |
Source code in src/easydynamics/sample_model/components/model_component.py
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 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 | |
__init__(unit='meV', display_name=None, unique_name=None)
Initialize the ModelComponent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
The unit of the model component. Default is 'meV'. |
'meV'
|
display_name
|
str | None
|
A human-readable name for the component. Default is None. |
None
|
unique_name
|
str | None
|
A unique identifier for the component. Default is None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If unit is not a string or scipp Unit. |
Source code in src/easydynamics/sample_model/components/model_component.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
__repr__()
Return a string representation of the ModelComponent.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the ModelComponent. |
Source code in src/easydynamics/sample_model/components/model_component.py
224 225 226 227 228 229 230 231 | |
convert_unit(unit)
Convert the unit of the Parameters in the component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str or Unit
|
The new unit to convert to. |
required |
Source code in src/easydynamics/sample_model/components/model_component.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
evaluate(x)
abstractmethod
Abstract method to evaluate the model component at input x. Must be implemented by subclasses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list[Numeric] | ndarray | Variable | DataArray
|
Input values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Evaluated function values. |
Source code in src/easydynamics/sample_model/components/model_component.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
fix_all_parameters()
Fix all parameters in the model component.
Source code in src/easydynamics/sample_model/components/model_component.py
88 89 90 91 92 93 | |
free_all_parameters()
Free all parameters in the model component.
Source code in src/easydynamics/sample_model/components/model_component.py
95 96 97 98 | |
unit
property
writable
Get the unit.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The unit of the model component. |
validate_unit(unit)
staticmethod
Validate that the unit is either a string or a scipp Unit.
Raises:
| Type | Description |
|---|---|
TypeError
|
If unit is not a string or scipp Unit. |
Source code in src/easydynamics/sample_model/components/model_component.py
173 174 175 176 177 178 179 180 181 182 183 | |
polynomial
Polynomial
Bases: ModelComponent
Polynomial function component.
The intensity is given by $$ I(x) = c_0 + c_1 x + c_2 x^2 + ... + c_N x^N, $$ where \(C_i\) are the coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coefficients
|
list or tuple
|
Coefficients c0, c1, ..., cN |
(0.0,)
|
unit
|
str or Unit
|
Unit of the Polynomial component. |
'meV'
|
display_name
|
str
|
Display name of the Polynomial component. |
'Polynomial'
|
unique_name
|
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
coefficients |
list of Parameter
|
Coefficients of the polynomial as Parameters. |
unit |
str
|
Unit of the Polynomial component. |
display_name |
str
|
Display name of the Polynomial component. |
unique_name |
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
Source code in src/easydynamics/sample_model/components/polynomial.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 | |
__init__(coefficients=(0.0,), unit='meV', display_name='Polynomial', unique_name=None)
Initialize the Polynomial component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coefficients
|
list or tuple
|
Coefficients c0, c1, ..., cN |
(0.0,)
|
unit
|
str or Unit
|
Unit of the Polynomial component. |
'meV'
|
display_name
|
str
|
Display name of the Polynomial component. |
'Polynomial'
|
unique_name
|
str or None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If coefficients is not a sequence of numbers or Parameters. |
ValueError
|
If coefficients is an empty sequence. |
TypeError
|
If any item in coefficients is not a number or Parameter. |
UnitError
|
If unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/polynomial.py
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 | |
__repr__()
Return a string representation of the Polynomial.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Polynomial. |
Source code in src/easydynamics/sample_model/components/polynomial.py
244 245 246 247 248 249 250 251 252 253 | |
coefficient_values()
Get the coefficients of the polynomial as a list.
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: The coefficient values of the polynomial. |
Source code in src/easydynamics/sample_model/components/polynomial.py
144 145 146 147 148 149 150 151 | |
coefficients
property
writable
Get the coefficients of the polynomial as a list of Parameters.
Returns:
| Type | Description |
|---|---|
list[Parameter]
|
list[Parameter]: The coefficients of the polynomial. |
convert_unit(unit)
Convert the unit of the polynomial.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str or Unit
|
The target unit to convert to. |
required |
Raises:
| Type | Description |
|---|---|
UnitError
|
If the provided unit is not a string or sc.Unit. |
Source code in src/easydynamics/sample_model/components/polynomial.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
degree
property
writable
Get the degree of the polynomial.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The degree of the polynomial. |
evaluate(x)
Evaluate the Polynomial at the given x values.
The intensity is given by $$ I(x) = c_0 + c_1 x + c_2 x^2 + ... + c_N x^N, $$ where \(C_i\) are the coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values at which to evaluate the Polynomial. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The evaluated Polynomial at the given x values. |
Source code in src/easydynamics/sample_model/components/polynomial.py
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 | |
get_all_variables()
Get all parameters from the model component.
Returns: List[Parameter]: List of parameters in the component.
Source code in src/easydynamics/sample_model/components/polynomial.py
211 212 213 214 215 216 217 | |
voigt
Voigt
Bases: CreateParametersMixin, ModelComponent
Voigt profile, a convolution of Gaussian and Lorentzian. If the center is not provided, it will be centered at 0 and fixed, which is typically what you want in QENS.
Use scipy.special.voigt_profile to evaluate the Voigt profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Total area under the curve. |
1.0
|
center
|
Int | float | None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int | float
|
Standard deviation of the Gaussian part. |
1.0
|
lorentzian_width
|
Int | float
|
Half width at half max (HWHM) of the Lorentzian part. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'Voigt'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
area |
Parameter
|
Total area under the curve. |
center |
Parameter
|
Center of the Voigt profile. |
gaussian_width |
Parameter
|
Standard deviation of the Gaussian part. |
lorentzian_width |
Parameter
|
Half width at half max (HWHM) of the Lorentzian part. |
unit |
str | Unit
|
Unit of the parameters. |
display_name |
str | None
|
Display name of the component. |
unique_name |
str | None
|
Unique name of the component. |
Source code in src/easydynamics/sample_model/components/voigt.py
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 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 | |
__init__(area=1.0, center=None, gaussian_width=1.0, lorentzian_width=1.0, unit='meV', display_name='Voigt', unique_name=None)
Initialize a Voigt component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int | float
|
Total area under the curve. |
1.0
|
center
|
Int | float | None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int | float
|
Standard deviation of the Gaussian part. |
1.0
|
lorentzian_width
|
Int | float
|
Half width at half max (HWHM) of the Lorentzian part. |
1.0
|
unit
|
str | Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str | None
|
Display name of the component. |
'Voigt'
|
unique_name
|
str | None
|
Unique name of the component. If None, a unique_name is automatically generated. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If any of the parameters are not of the correct type. |
ValueError
|
If any of the parameters are not valid (e.g. negative widths). |
Source code in src/easydynamics/sample_model/components/voigt.py
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 | |
__repr__()
Return a string representation of the Voigt.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the Voigt. |
Source code in src/easydynamics/sample_model/components/voigt.py
240 241 242 243 244 245 246 247 248 249 250 251 | |
area
property
writable
Get the area parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The area parameter. |
center
property
writable
Get the center parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The center parameter. |
evaluate(x)
Evaluate the Voigt at the given x values.
If x is a scipp Variable, the unit of the Voigt will be converted to match x. The Voigt evaluates to the convolution of a Gaussian with sigma gaussian_width and a Lorentzian with half width at half max lorentzian_width, centered at center, with area equal to area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list[Numeric] | ndarray | Variable | DataArray
|
The x values at which to evaluate the Voigt. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The intensity of the Voigt at the given x values. |
Source code in src/easydynamics/sample_model/components/voigt.py
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 | |
gaussian_width
property
writable
Get the Gaussian width parameter.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The Gaussian width parameter. |
lorentzian_width
property
writable
Get the Lorentzian width parameter (HWHM).
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The Lorentzian width parameter. |
diffusion_model
BrownianTranslationalDiffusion
Bases: DiffusionModelBase
Model of Brownian translational diffusion, consisting of a Lorentzian function for each Q-value, where the width is given by \(D Q^2\), where \(D\) is the diffusion coefficient. The area of the Lorentzians is given by the scale parameter multiplied by the QISF, which is 1 for this model. The EISF is 0 for this model, so there is no delta function component. Q is assumed to have units of 1/angstrom. Creates ComponentCollections with Lorentzian components for given Q-values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'BrownianTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the diffusion model. |
scale |
Parameter
|
Scale parameter of the diffusion model. |
diffusion_coefficient |
Parameter
|
Diffusion coefficient D in m^2/s. |
Example usage:
Q=np.linspace(0.5,2,7) energy=np.linspace(-2, 2, 501) scale=1.0 diffusion_coefficient = 2.4e-9 # m^2/s diffusion_model=BrownianTranslationalDiffusion(display_name="DiffusionModel", scale=scale, diffusion_coefficient= diffusion_coefficient) component_collections=diffusion_model.create_component_collections(Q) See also the examples.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
__init__(display_name='BrownianTranslationalDiffusion', unique_name=None, unit='meV', scale=1.0, diffusion_coefficient=1.0)
Initialize a new BrownianTranslationalDiffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'BrownianTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If scale or diffusion_coefficient is not a number. |
ValueError
|
If scale is negative. |
UnitError
|
If unit is not a string or scipp Unit. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
__repr__()
String representation of the BrownianTranslationalDiffusion model.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String representation of the BrownianTranslationalDiffusion model. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
333 334 335 336 337 338 339 340 341 342 343 344 | |
calculate_EISF(Q)
Calculate the Elastic Incoherent Structure Factor (EISF) for the Brownian translational diffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: EISF values (dimensionless). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
calculate_QISF(Q)
Calculate the Quasi-Elastic Incoherent Structure Factor (QISF).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: QISF values (dimensionless). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
calculate_width(Q)
Calculate the half-width at half-maximum (HWHM) for the diffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: HWHM values in the unit of the model (e.g., meV). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
create_component_collections(Q, component_display_name='Brownian translational diffusion')
Create ComponentCollection components for the Brownian translational diffusion model at given Q values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Number, list, or np.ndarray
|
Scattering vector values. |
required |
component_display_name
|
str
|
Name of the Lorentzian component. |
'Brownian translational diffusion'
|
Returns:
| Type | Description |
|---|---|
List[ComponentCollection]
|
List[ComponentCollection]: List of ComponentCollections with Lorentzian components for each Q value. Each Lorentzian has a width given by \(D*Q^2\) and an area given by the scale parameter multiplied by the QISF (which is 1 for this model). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If component_display_name is not a string. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
diffusion_coefficient
property
writable
Get the diffusion coefficient parameter D.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
Diffusion coefficient D in m^2/s. |
JumpTranslationalDiffusion
Bases: DiffusionModelBase
Model of Jump translational diffusion. The model consists of a Lorentzian function for each Q-value, where the width is given by
where \(D\) is the diffusion coefficient and \(t\) is the relaxation time. Q is assumed to have units of 1/angstrom. Creates ComponentCollections with Lorentzian components for given Q-values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'JumpTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
relaxation_time
|
Numeric
|
Relaxation time t in ps. Defaults to 1.0. |
1.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the diffusion model. |
scale |
Parameter
|
Scale parameter of the diffusion model. |
diffusion_coefficient |
Parameter
|
Diffusion coefficient D in m^2/s. |
relaxation_time |
Parameter
|
Relaxation time t in ps. |
Example usage:
Q = np.linspace(0.5, 2, 7) energy = np.linspace(-2, 2, 501) scale = 1.0 diffusion_coefficient = 2.4e-9 # m^2/s relaxation_time = 1.0 # ps diffusion_model=JumpTranslationalDiffusion( scale = scale, diffusion_coefficient = (diffusion_coefficient,) relaxation_time=relaxation_time) component_collections= diffusion_model.create_component_collections(Q) See also the examples.
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
__init__(display_name='JumpTranslationalDiffusion', unique_name=None, unit='meV', scale=1.0, diffusion_coefficient=1.0, relaxation_time=1.0)
Initialize a new JumpTranslationalDiffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'JumpTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
relaxation_time
|
Numeric
|
Relaxation time t in ps. Defaults to 1.0. |
1.0
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If scale, diffusion_coefficient, or relaxation_time are not numbers. |
ValueError
|
If scale is negative. |
UnitError
|
If unit is not a valid unit string or scipp Unit. |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
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 | |
__repr__()
String representation of the JumpTranslationalDiffusion model.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String representation of the JumpTranslationalDiffusion model. |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
382 383 384 385 386 387 388 389 390 391 392 393 | |
calculate_EISF(Q)
Calculate the Elastic Incoherent Structure Factor (EISF).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Q_type
|
Scattering vector in 1/angstrom. Can be a single value or an array of values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: EISF values (dimensionless). |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
224 225 226 227 228 229 230 231 232 233 234 235 236 | |
calculate_QISF(Q)
Calculate the Quasi-Elastic Incoherent Structure Factor (QISF).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Q_type
|
Scattering vector in 1/angstrom. Can be a single value or an array of values. |
required |
Returns: np.ndarray: QISF values (dimensionless).
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
238 239 240 241 242 243 244 245 246 247 248 249 250 | |
calculate_width(Q)
Calculate the half-width at half-maximum (HWHM) for the diffusion model. \(\Gamma(Q) = Q^2/(1+D t Q^2)\), where \(D\) is the diffusion coefficient and \(t\) is the relaxation time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Q_type
|
Scattering vector in 1/angstrom. Can be a single value or an array of values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: HWHM values in the unit of the model (e.g., meV). |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
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 | |
create_component_collections(Q, component_display_name='Jump translational diffusion')
Create ComponentCollection components for the diffusion model at given Q values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Q_type
|
Scattering vector in 1/angstrom. Can be a single value or an array of values. |
required |
component_display_name
|
str
|
Name of the Jump Diffusion Lorentzian component. |
'Jump translational diffusion'
|
Returns:
| Type | Description |
|---|---|
List[ComponentCollection]
|
List[ComponentCollection]: List of ComponentCollections with Jump Diffusion Lorentzian components. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If component_display_name is not a string. |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
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 | |
diffusion_coefficient
property
writable
Get the diffusion coefficient parameter D.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
Diffusion coefficient D. |
relaxation_time
property
writable
Get the relaxation time parameter t.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
Relaxation time t in ps. |
brownian_translational_diffusion
BrownianTranslationalDiffusion
Bases: DiffusionModelBase
Model of Brownian translational diffusion, consisting of a Lorentzian function for each Q-value, where the width is given by \(D Q^2\), where \(D\) is the diffusion coefficient. The area of the Lorentzians is given by the scale parameter multiplied by the QISF, which is 1 for this model. The EISF is 0 for this model, so there is no delta function component. Q is assumed to have units of 1/angstrom. Creates ComponentCollections with Lorentzian components for given Q-values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'BrownianTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the diffusion model. |
scale |
Parameter
|
Scale parameter of the diffusion model. |
diffusion_coefficient |
Parameter
|
Diffusion coefficient D in m^2/s. |
Example usage:
Q=np.linspace(0.5,2,7) energy=np.linspace(-2, 2, 501) scale=1.0 diffusion_coefficient = 2.4e-9 # m^2/s diffusion_model=BrownianTranslationalDiffusion(display_name="DiffusionModel", scale=scale, diffusion_coefficient= diffusion_coefficient) component_collections=diffusion_model.create_component_collections(Q) See also the examples.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
__init__(display_name='BrownianTranslationalDiffusion', unique_name=None, unit='meV', scale=1.0, diffusion_coefficient=1.0)
Initialize a new BrownianTranslationalDiffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'BrownianTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If scale or diffusion_coefficient is not a number. |
ValueError
|
If scale is negative. |
UnitError
|
If unit is not a string or scipp Unit. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
__repr__()
String representation of the BrownianTranslationalDiffusion model.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String representation of the BrownianTranslationalDiffusion model. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
333 334 335 336 337 338 339 340 341 342 343 344 | |
calculate_EISF(Q)
Calculate the Elastic Incoherent Structure Factor (EISF) for the Brownian translational diffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: EISF values (dimensionless). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
calculate_QISF(Q)
Calculate the Quasi-Elastic Incoherent Structure Factor (QISF).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: QISF values (dimensionless). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
calculate_width(Q)
Calculate the half-width at half-maximum (HWHM) for the diffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray | Numeric | list | ArrayLike
|
Scattering vector in 1/angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: HWHM values in the unit of the model (e.g., meV). |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
create_component_collections(Q, component_display_name='Brownian translational diffusion')
Create ComponentCollection components for the Brownian translational diffusion model at given Q values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Number, list, or np.ndarray
|
Scattering vector values. |
required |
component_display_name
|
str
|
Name of the Lorentzian component. |
'Brownian translational diffusion'
|
Returns:
| Type | Description |
|---|---|
List[ComponentCollection]
|
List[ComponentCollection]: List of ComponentCollections with Lorentzian components for each Q value. Each Lorentzian has a width given by \(D*Q^2\) and an area given by the scale parameter multiplied by the QISF (which is 1 for this model). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If component_display_name is not a string. |
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
diffusion_coefficient
property
writable
Get the diffusion coefficient parameter D.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
Diffusion coefficient D in m^2/s. |
diffusion_model_base
DiffusionModelBase
Bases: ModelBase
Base class for constructing diffusion models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'MyDiffusionModel'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the diffusion model. |
scale |
Parameter
|
Scale parameter of the diffusion model. |
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_model_base.py
13 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 140 | |
__init__(display_name='MyDiffusionModel', unique_name=None, scale=1.0, unit='meV')
Initialize a new DiffusionModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'MyDiffusionModel'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If scale is not a number. |
UnitError
|
If unit is not a string or scipp Unit, or if it cannot be converted to meV. |
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_model_base.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 | |
__repr__()
String representation of the Diffusion model.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String representation of the DiffusionModel. |
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_model_base.py
134 135 136 137 138 139 140 | |
scale
property
writable
Get the scale parameter of the diffusion model.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
scale parameter of the diffusion model |
unit
property
writable
Get the unit of the energy axis of the DiffusionModel.
Returns:
| Type | Description |
|---|---|
str | Unit | None
|
Unit of the DiffusionModel. |
jump_translational_diffusion
JumpTranslationalDiffusion
Bases: DiffusionModelBase
Model of Jump translational diffusion. The model consists of a Lorentzian function for each Q-value, where the width is given by
where \(D\) is the diffusion coefficient and \(t\) is the relaxation time. Q is assumed to have units of 1/angstrom. Creates ComponentCollections with Lorentzian components for given Q-values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'JumpTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
relaxation_time
|
Numeric
|
Relaxation time t in ps. Defaults to 1.0. |
1.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the diffusion model. |
scale |
Parameter
|
Scale parameter of the diffusion model. |
diffusion_coefficient |
Parameter
|
Diffusion coefficient D in m^2/s. |
relaxation_time |
Parameter
|
Relaxation time t in ps. |
Example usage:
Q = np.linspace(0.5, 2, 7) energy = np.linspace(-2, 2, 501) scale = 1.0 diffusion_coefficient = 2.4e-9 # m^2/s relaxation_time = 1.0 # ps diffusion_model=JumpTranslationalDiffusion( scale = scale, diffusion_coefficient = (diffusion_coefficient,) relaxation_time=relaxation_time) component_collections= diffusion_model.create_component_collections(Q) See also the examples.
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
__init__(display_name='JumpTranslationalDiffusion', unique_name=None, unit='meV', scale=1.0, diffusion_coefficient=1.0, relaxation_time=1.0)
Initialize a new JumpTranslationalDiffusion model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the diffusion model. |
'JumpTranslationalDiffusion'
|
unique_name
|
str | None
|
Unique name of the diffusion model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit
|
Unit of the diffusion model. Must be convertible to meV. Defaults to "meV". |
'meV'
|
scale
|
Numeric
|
Scale factor for the diffusion model. Must be a non-negative number. Defaults to 1.0. |
1.0
|
diffusion_coefficient
|
Numeric
|
Diffusion coefficient D in m^2/s. Defaults to 1.0. |
1.0
|
relaxation_time
|
Numeric
|
Relaxation time t in ps. Defaults to 1.0. |
1.0
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If scale, diffusion_coefficient, or relaxation_time are not numbers. |
ValueError
|
If scale is negative. |
UnitError
|
If unit is not a valid unit string or scipp Unit. |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
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 | |
__repr__()
String representation of the JumpTranslationalDiffusion model.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String representation of the JumpTranslationalDiffusion model. |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
382 383 384 385 386 387 388 389 390 391 392 393 | |
calculate_EISF(Q)
Calculate the Elastic Incoherent Structure Factor (EISF).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Q_type
|
Scattering vector in 1/angstrom. Can be a single value or an array of values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: EISF values (dimensionless). |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
224 225 226 227 228 229 230 231 232 233 234 235 236 | |
calculate_QISF(Q)
Calculate the Quasi-Elastic Incoherent Structure Factor (QISF).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Q_type
|
Scattering vector in 1/angstrom. Can be a single value or an array of values. |
required |
Returns: np.ndarray: QISF values (dimensionless).
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
238 239 240 241 242 243 244 245 246 247 248 249 250 | |
calculate_width(Q)
Calculate the half-width at half-maximum (HWHM) for the diffusion model. \(\Gamma(Q) = Q^2/(1+D t Q^2)\), where \(D\) is the diffusion coefficient and \(t\) is the relaxation time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Q_type
|
Scattering vector in 1/angstrom. Can be a single value or an array of values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: HWHM values in the unit of the model (e.g., meV). |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
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 | |
create_component_collections(Q, component_display_name='Jump translational diffusion')
Create ComponentCollection components for the diffusion model at given Q values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
Q_type
|
Scattering vector in 1/angstrom. Can be a single value or an array of values. |
required |
component_display_name
|
str
|
Name of the Jump Diffusion Lorentzian component. |
'Jump translational diffusion'
|
Returns:
| Type | Description |
|---|---|
List[ComponentCollection]
|
List[ComponentCollection]: List of ComponentCollections with Jump Diffusion Lorentzian components. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If component_display_name is not a string. |
Source code in src/easydynamics/sample_model/diffusion_model/jump_translational_diffusion.py
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 | |
diffusion_coefficient
property
writable
Get the diffusion coefficient parameter D.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
Diffusion coefficient D. |
relaxation_time
property
writable
Get the relaxation time parameter t.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
Relaxation time t in ps. |
instrument_model
InstrumentModel
Bases: NewBase
InstrumentModel represents a model of the instrument in an experiment at various Q. It can contain a model of the resolution function for convolutions, of the background and an offset in the energy axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str | None
|
The display name of the InstrumentModel. Default is "MyInstrumentModel". |
'MyInstrumentModel'
|
unique_name
|
str | None
|
The unique name of the InstrumentModel. Default is None. |
None
|
Q
|
ndarray | list | Variable | None
|
The Q values where the instrument is modelled. |
None
|
resolution_model
|
ResolutionModel | None
|
The resolution model of the instrument. If None, an empty resolution model is created and no resolution convolution is carried out. Default is None. |
None
|
background_model
|
BackgroundModel | None
|
The background model of the instrument. If None, an empty background model is created, and the background evaluates to 0. Default is None. |
None
|
energy_offset
|
float | int | None
|
Template energy offset of the instrument. Will be copied to each Q value. If None, the energy offset will be 0. Default is None. |
None
|
unit
|
str | Unit
|
The unit of the energy axis. Default is 'meV'. |
'meV'
|
Attributes:
| Name | Type | Description |
|---|---|---|
resolution_model |
ResolutionModel
|
The resolution model of the instrument. |
background_model |
BackgroundModel
|
The background model of the instrument. |
Q |
ndarray | None
|
The Q values where the instrument is modelled. |
energy_offset |
Parameter
|
The template energy offset Parameter of the instrument. Will be copied to each Q value. |
unit |
str | Unit
|
The unit of the energy axis. |
Source code in src/easydynamics/sample_model/instrument_model.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 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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
Q
property
writable
Get the Q values of the InstrumentModel.
Returns:
| Type | Description |
|---|---|
ndarray | None
|
np.ndarray or None: The Q values of the InstrumentModel, or None if not set |
__init__(display_name='MyInstrumentModel', unique_name=None, Q=None, resolution_model=None, background_model=None, energy_offset=None, unit='meV')
Initialize an InstrumentModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str | None
|
The display name of the InstrumentModel. Default is "MyInstrumentModel". |
'MyInstrumentModel'
|
unique_name
|
str | None
|
The unique name of the InstrumentModel. Default is None. |
None
|
Q
|
ndarray | list | Variable | None
|
The Q values where the instrument is modelled. |
None
|
resolution_model
|
ResolutionModel | None
|
The resolution model of the instrument. If None, an empty resolution model is created and no resolution convolution is carried out. Default is None. |
None
|
background_model
|
BackgroundModel | None
|
The background model of the instrument. If None, an empty background model is created, and the background evaluates to 0. Default is None. |
None
|
energy_offset
|
float | int | None
|
Template energy offset of the instrument. Will be copied to each Q value. If None, the energy offset will be 0. Default is None. |
None
|
unit
|
str | Unit
|
The unit of the energy axis. Default is 'meV'. |
'meV'
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If resolution_model is not a ResolutionModel or None |
TypeError
|
If background_model is not a BackgroundModel or None |
TypeError
|
If energy_offset is not a number or None |
UnitError
|
If unit is not a valid unit string or scipp Unit. |
Source code in src/easydynamics/sample_model/instrument_model.py
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 | |
__repr__()
Return a string representation of the InstrumentModel.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the InstrumentModel. |
Source code in src/easydynamics/sample_model/instrument_model.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
background_model
property
writable
Get the background model of the instrument.
Returns:
| Name | Type | Description |
|---|---|---|
BackgroundModel |
BackgroundModel
|
The background model of the instrument. |
convert_unit(unit_str)
Convert the unit of the InstrumentModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_str
|
str | Unit
|
The unit to convert to. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If unit_str is not a string or scipp Unit. |
ValueError
|
If unit_str is not a valid unit string or scipp Unit. |
Source code in src/easydynamics/sample_model/instrument_model.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
energy_offset
property
writable
Get the energy offset template parameter of the instrument model.
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The energy offset template parameter of the instrument model. |
fix_resolution_parameters()
Fix all parameters in the resolution model.
Source code in src/easydynamics/sample_model/instrument_model.py
347 348 349 | |
free_resolution_parameters()
Free all parameters in the resolution model.
Source code in src/easydynamics/sample_model/instrument_model.py
351 352 353 | |
get_all_variables(Q_index=None)
Get all variables in the InstrumentModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int | None
|
The index of the Q value to get variables for. If None, get variables for all Q values. |
None
|
Returns:
| Type | Description |
|---|---|
list[Parameter]
|
list[Parameter]: A list of all variables in the InstrumentModel. If Q_index is specified, only variables from the ComponentCollection at the given Q index are included. Otherwise, all variables in the InstrumentModel are included. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If Q_index is not an int or None. |
IndexError
|
If Q_index is out of bounds for the Q values in the InstrumentModel. |
Source code in src/easydynamics/sample_model/instrument_model.py
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 | |
get_energy_offset_at_Q(Q_index)
Get the energy offset Parameter at a specific Q index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int
|
The index of the Q value to get the energy offset for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
The energy offset Parameter at the specified Q index. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no Q values are set in the InstrumentModel. |
IndexError
|
If Q_index is out of bounds. |
Source code in src/easydynamics/sample_model/instrument_model.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
resolution_model
property
writable
Get the resolution model of the instrument.
Returns:
| Name | Type | Description |
|---|---|---|
ResolutionModel |
ResolutionModel
|
The resolution model of the instrument. |
unit
property
writable
Get the unit of the InstrumentModel.
Returns:
| Type | Description |
|---|---|
str | Unit
|
The unit of the InstrumentModel. |
model_base
ModelBase
Bases: ModelBase
Base class for Sample Models.
Contains common functionality for models with components and Q dependence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyModelBase'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
ArrayLike | Variable | None
|
Q values for the model. If None, Q is not set. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the model. |
components |
list[ModelComponent]
|
List of ModelComponents in the model. |
Q |
ArrayLike | Variable | None
|
Q values of the model. |
Source code in src/easydynamics/sample_model/model_base.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 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 371 372 373 374 375 376 | |
Q
property
writable
Get the Q values of the SampleModel.
Returns:
| Type | Description |
|---|---|
ndarray | None
|
np.ndarray | None: The Q values of the SampleModel, or None if not set. |
__init__(display_name='MyModelBase', unique_name=None, unit='meV', components=None, Q=None)
Initialize the ModelBase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyModelBase'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
ArrayLike | Variable | None
|
Q values for the model. If None, Q is not set. |
None
|
Source code in src/easydynamics/sample_model/model_base.py
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 | |
__repr__()
Return a string representation of the ModelBase.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the ModelBase. |
Source code in src/easydynamics/sample_model/model_base.py
367 368 369 370 371 372 373 374 375 376 | |
append_component(component)
Append a ModelComponent or ComponentCollection to the SampleModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ModelComponent | ComponentCollection
|
The ModelComponent or ComponentCollection to append. |
required |
Source code in src/easydynamics/sample_model/model_base.py
123 124 125 126 127 128 129 130 131 132 | |
clear_components()
Clear all ModelComponents from the SampleModel.
Source code in src/easydynamics/sample_model/model_base.py
145 146 147 148 | |
components
property
writable
Get the components of the SampleModel.
Returns:
| Type | Description |
|---|---|
list[ModelComponent]
|
list[ModelComponent]: The components of the SampleModel. |
convert_unit(unit)
Convert the unit of the ComponentCollection and all its components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
The new unit to convert to. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the provided unit is not a string or sc.Unit. |
UnitError
|
If the provided unit is not compatible with the current unit. |
Source code in src/easydynamics/sample_model/model_base.py
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 | |
evaluate(x)
Evaluate the sample model at all Q for the given x values.
x (Numeric | list | np.ndarray | sc.Variable | sc.DataArray): Energy axis values to evaluate the model at. If a scipp Variable or DataArray is provided, the unit of the model will be converted to match the unit of x for evaluation, and the result will be returned in the same unit as x.
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
list[np.ndarray]: A list of numpy arrays containing the evaluated model values for each Q. The length of the list will match the number of Q values in the model. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there are no components in the model to evaluate. |
Source code in src/easydynamics/sample_model/model_base.py
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 | |
fix_all_parameters()
Fix all Parameters in all ComponentCollections.
Source code in src/easydynamics/sample_model/model_base.py
273 274 275 276 | |
free_all_parameters()
Free all Parameters in all ComponentCollections.
Source code in src/easydynamics/sample_model/model_base.py
278 279 280 281 | |
get_all_variables(Q_index=None)
Get all Parameters and Descriptors from all ComponentCollections in the ModelBase. Parameters Ignores the Parameters and Descriptors in self._components as these are just templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int | None
|
If None, get variables for all ComponentCollections. If int, get variables for the ComponentCollection at this index. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[Parameter]
|
list[Parameter]: A list of all Parameters and Descriptors from the ComponentCollections in the ModelBase. |
Source code in src/easydynamics/sample_model/model_base.py
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 | |
get_component_collection(Q_index)
Get the ComponentCollection at the given Q index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int
|
The index of the desired ComponentCollection. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ComponentCollection |
ComponentCollection
|
The ComponentCollection at the |
ComponentCollection
|
specified Q index. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If Q_index is not an int. |
IndexError
|
If Q_index is out of bounds for the number of ComponentCollections. |
Source code in src/easydynamics/sample_model/model_base.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
remove_component(unique_name)
Remove a ModelComponent from the SampleModel by its unique name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unique_name
|
str
|
The unique name of the ModelComponent to remove. |
required |
Source code in src/easydynamics/sample_model/model_base.py
134 135 136 137 138 139 140 141 142 143 | |
unit
property
writable
Get the unit of the ComponentCollection.
Returns:
| Type | Description |
|---|---|
str | Unit
|
str | sc.Unit |None: The unit of the ComponentCollection. |
resolution_model
ResolutionModel
Bases: ModelBase
ResolutionModel represents a model of the instrment resolution in an experiment at various Q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyResolutionModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
Q_type | None
|
Q values for the model. If None, Q is not set. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the model. |
components |
list[ModelComponent]
|
List of ModelComponents in the model. |
Q |
ndarray | Numeric | list | ArrayLike | Variable | None
|
Q values of the model. |
Source code in src/easydynamics/sample_model/resolution_model.py
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 | |
__init__(display_name='MyResolutionModel', unique_name=None, unit='meV', components=None, Q=None)
Initialize a ResolutionModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MyResolutionModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. Defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
Q_type | None
|
Q values for the model. If None, Q is not set. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If components is not a ModelComponent or ComponentCollection. |
ValueError
|
If Q is not a valid Q_type. |
Source code in src/easydynamics/sample_model/resolution_model.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 | |
append_component(component)
Append a component to the ResolutionModel.
Does not allow DeltaFunction or Polynomial components, as these are not physical resolution components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ModelComponent | ComponentCollection
|
Component(s) to append. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the component is a DeltaFunction or Polynomial |
Source code in src/easydynamics/sample_model/resolution_model.py
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 | |
sample_model
SampleModel
Bases: ModelBase
SampleModel represents a model of a sample with components and diffusion models, parameterized by Q and optionally temperature. Generates ComponentCollections for each Q value, combining components from the base model and diffusion models.
Applies detailed balancing based on temperature if provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MySampleModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. If None, defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
(Number, list, ndarray, array | None)
|
Q values for the model. If None, Q is not set. |
None
|
diffusion_models
|
DiffusionModelBase | list[DiffusionModelBase] | None
|
Diffusion models to include in the SampleModel. If None, no diffusion models are added. |
None
|
temperature
|
float | None
|
Temperature for detailed balancing. If None, no detailed balancing is applied. |
None
|
temperature_unit
|
str | Unit
|
Unit of the temperature. Defaults to "K". |
'K'
|
divide_by_temperature
|
bool
|
Whether to divide the detailed balance factor by temperature. Defaults to True. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str | Unit
|
Unit of the model. |
components |
list[ModelComponent]
|
List of ModelComponents in the model. |
Q |
ndarray | Numeric | list | ArrayLike | Variable | None
|
Q values of the model. |
diffusion_models |
list[DiffusionModelBase]
|
List of diffusion models in the SampleModel. |
temperature |
Parameter | None
|
Temperature Parameter for detailed balancing, or None if not set. |
divide_by_temperature |
bool
|
Whether to divide the detailed balance factor by temperature. |
Source code in src/easydynamics/sample_model/sample_model.py
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 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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
__init__(display_name='MySampleModel', unique_name=None, unit='meV', components=None, Q=None, diffusion_models=None, temperature=None, temperature_unit='K', divide_by_temperature=True)
Initialize the SampleModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the model. |
'MySampleModel'
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
unit
|
str | Unit | None
|
Unit of the model. If None, defaults to "meV". |
'meV'
|
components
|
ModelComponent | ComponentCollection | None
|
Template components of the model. If None, no components are added. These components are copied into ComponentCollections for each Q value. |
None
|
Q
|
(Number, list, ndarray, array | None)
|
Q values for the model. If None, Q is not set. |
None
|
diffusion_models
|
DiffusionModelBase | list[DiffusionModelBase] | None
|
Diffusion models to include in the SampleModel. If None, no diffusion models are added. |
None
|
temperature
|
float | None
|
Temperature for detailed balancing. If None, no detailed balancing is applied. |
None
|
temperature_unit
|
str | Unit
|
Unit of the temperature. Defaults to "K". |
'K'
|
divide_by_temperature
|
bool
|
Whether to divide the detailed balance factor by temperature. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If diffusion_models is not a DiffusionModelBase, a list of DiffusionModelBase, or None. |
TypeError
|
If temperature is not a number or None. |
ValueError
|
If temperature is negative. |
TypeError
|
If divide_by_temperature is not a bool. |
Source code in src/easydynamics/sample_model/sample_model.py
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 | |
__repr__()
Return a string representation of the SampleModel.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the SampleModel. |
Source code in src/easydynamics/sample_model/sample_model.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
append_diffusion_model(diffusion_model)
Append a DiffusionModel to the SampleModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diffusion_model
|
DiffusionModelBase
|
The DiffusionModel to append. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the diffusion_model is not a DiffusionModelBase |
Source code in src/easydynamics/sample_model/sample_model.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
clear_diffusion_models()
Clear all DiffusionModels from the SampleModel.
Source code in src/easydynamics/sample_model/sample_model.py
192 193 194 195 | |
convert_temperature_unit(unit)
Convert the unit of the temperature Parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | Unit
|
The unit to convert the temperature Parameter to. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If temperature is not set or conversion fails. |
Source code in src/easydynamics/sample_model/sample_model.py
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 | |
diffusion_models
property
writable
Get the diffusion models of the SampleModel.
Returns:
| Type | Description |
|---|---|
list[DiffusionModelBase]
|
list[DiffusionModelBase]: The diffusion models of the SampleModel. |
divide_by_temperature
property
writable
Get whether to divide the detailed balance factor by temperature.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the detailed balance factor is divided by temperature, False otherwise. |
evaluate(x)
Evaluate the sample model at all Q for the given x values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | list | ndarray | Variable | DataArray
|
The x values to evaluate the model at. Can be a number, list, numpy array, scipp Variable, or scipp DataArray. |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
list[np.ndarray]: List of evaluated model values for each Q. |
Source code in src/easydynamics/sample_model/sample_model.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
get_all_variables(Q_index=None)
Get all Parameters and Descriptors from all ComponentCollections in the SampleModel.
Also includes temperature if set and all variables from diffusion models. Ignores the Parameters and Descriptors in self._components as these are just templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int | None
|
If specified, only get variables from the ComponentCollection at the given Q index. If None, get variables from all ComponentCollections. |
None
|
Source code in src/easydynamics/sample_model/sample_model.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
remove_diffusion_model(name)
Remove a DiffusionModel from the SampleModel by unique name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The unique name of the DiffusionModel to remove. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no DiffusionModel with the given unique name is found. |
Source code in src/easydynamics/sample_model/sample_model.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
temperature
property
writable
Get the temperature of the SampleModel.
Returns:
| Type | Description |
|---|---|
Parameter | None
|
Parameter | None: The temperature Parameter of the SampleModel, or None if not set. |
temperature_unit
property
writable
Get the temperature unit of the SampleModel.
Returns:
| Type | Description |
|---|---|
str | Unit
|
str | sc.Unit: The unit of the temperature Parameter. |