sample_model
BrownianTranslationalDiffusion
Bases: DiffusionModelBase
Model of Brownian translational diffusion, consisting of a
Lorentzian function for each Q-value, where the width is given by
:math:DQ^2. Q is assumed to have units of 1/angstrom. Creates
ComponentCollections with Lorentzian components for given Q-values.
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
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 | |
__init__(display_name='BrownianTranslationalDiffusion', unique_name=None, unit='meV', scale=1.0, diffusion_coefficient=1.0, diffusion_unit='m**2/s')
Initialize a new BrownianTranslationalDiffusion model.
Parameters
display_name : str Display name of the diffusion model. unique_name : str or None Unique name of the diffusion model. If None, a unique name is automatically generated. unit : str or sc.Unit, optional Energy unit for the underlying Lorentzian components. Defaults to "meV". scale : float or Parameter, optional Scale factor for the diffusion model. diffusion_coefficient : float or Parameter, optional Diffusion coefficient D. If a number is provided, it is assumed to be in the unit given by diffusion_unit. Defaults to 1.0. diffusion_unit : str, optional Unit for the diffusion coefficient D. Default is m2/s. Options are 'meV*Å2' or 'm**2/s'
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
__repr__()
String representation of the BrownianTranslationalDiffusion model.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
319 320 321 322 323 324 325 326 | |
calculate_EISF(Q)
Calculate the Elastic Incoherent Structure Factor (EISF) for the Brownian translational diffusion model.
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
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 180 181 182 | |
calculate_QISF(Q)
Calculate the Quasi-Elastic Incoherent Structure Factor (QISF).
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
np.ndarray QISF values (dimensionless).
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
calculate_width(Q)
Calculate the half-width at half-maximum (HWHM) for the diffusion model.
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
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
143 144 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.
Args:
Q : Number, list, or np.ndarray Scattering vector values. component_display_name : str Name of the Lorentzian component. Returns
List[ComponentCollection] List of ComponentCollections with Lorentzian components.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
diffusion_coefficient
property
writable
Get the diffusion coefficient parameter D.
Returns
Parameter Diffusion coefficient D.
scale
property
writable
Get the scale parameter of the diffusion model.
Returns
Parameter Scale parameter.
ComponentCollection
Bases: ModelBase
A model of the scattering from a sample, combining multiple model components.
Attributes
display_name : str Display name of the ComponentCollection. unit : str or sc.Unit Unit of the ComponentCollection.
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 | |
__contains__(item)
Check if a component with the given name or instance exists in the ComponentCollection.
Args:
item : str or ModelComponent The component name or instance to check for. Returns
bool True if the component exists, False otherwise.
Source code in src/easydynamics/sample_model/component_collection.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
__init__(unit='meV', display_name='MyComponentCollection', unique_name=None, components=None)
Initialize a new ComponentCollection.
Parameters
unit : str or sc.Unit, optional Unit of the sample model. Defaults to "meV". display_name : str Display name of the sample model. unique_name : str or None, optional Unique name of the sample model. Defaults to None. components : List[ModelComponent], optional Initial model components to add to the ComponentCollection.
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
__repr__()
Return a string representation of the ComponentCollection.
Returns
str
Source code in src/easydynamics/sample_model/component_collection.py
299 300 301 302 303 304 305 306 307 308 | |
clear_components()
Remove all components.
Source code in src/easydynamics/sample_model/component_collection.py
130 131 132 | |
convert_unit(unit)
Convert the unit of the ComponentCollection and all its components.
Source code in src/easydynamics/sample_model/component_collection.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
evaluate(x)
Evaluate the sum of all components.
Parameters
x : Number, list, np.ndarray, sc.Variable, or sc.DataArray Energy axis.
Returns
np.ndarray Evaluated model values.
Source code in src/easydynamics/sample_model/component_collection.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
evaluate_component(x, unique_name)
Evaluate a single component by name.
Parameters
x : Number, list, np.ndarray, sc.Variable, or sc.DataArray Energy axis. unique_name : str Component unique name.
Returns
np.ndarray Evaluated values for the specified component.
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
fix_all_parameters()
Fix all free parameters in the model.
Source code in src/easydynamics/sample_model/component_collection.py
266 267 268 269 | |
free_all_parameters()
Free all fixed parameters in the model.
Source code in src/easydynamics/sample_model/component_collection.py
271 272 273 274 | |
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/component_collection.py
163 164 165 166 167 168 169 170 | |
list_component_names()
List the names of all components in the model.
Returns
List[str] Component names.
Source code in src/easydynamics/sample_model/component_collection.py
119 120 121 122 123 124 125 126 127 128 | |
normalize_area()
Normalize the areas of all components so they sum to 1.
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
unit
property
writable
Get the unit of the ComponentCollection.
Returns
str or sc.Unit or None
DampedHarmonicOscillator
Bases: CreateParametersMixin, ModelComponent
Damped Harmonic Oscillator (DHO). 2areacenter^2width/pi / ( (x^2 - center^2)^2 + (2width*x)^2 )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the component. |
'DampedHarmonicOscillator'
|
center
|
Int or float
|
Resonance frequency, approximately the |
1.0
|
width
|
Int or float
|
Damping constant, approximately the |
1.0
|
area
|
Int or float
|
Area under the curve. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 DHO evaluates to 2areacenter^2width/pi / ((x^2 - center^2)^2 + (2width*x)^2)
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
width
property
writable
Get 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 in the ResolutionHandler. 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 or float or None
|
Center of the delta function. |
None
|
area
|
Int or float
|
Total area under the curve. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
display_name
|
str
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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.
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
Gaussian
Bases: CreateParametersMixin, ModelComponent
Gaussian function: area/(widthsqrt(2pi)) * exp(-0.5((x - center)/width)^2) 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 or Parameter)
|
Area of the Gaussian. |
1.0
|
center
|
(Int, float, None or Parameter)
|
Center of the Gaussian. |
None
|
width
|
(Int, float or Parameter)
|
Standard deviation. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
display_name
|
str
|
Name of the component. |
'Gaussian'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 Gaussian evaluates to area/(widthsqrt(2pi)) * exp(-0.5((x - center)/width)^2)
Source code in src/easydynamics/sample_model/components/gaussian.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
width
property
writable
Get the width parameter.
Lorentzian
Bases: CreateParametersMixin, ModelComponent
Lorentzian function: area*width / (pi * ( (x - center)^2 + width^2 ) ) 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 or Parameter)
|
Area of the Lorentzian. |
1.0
|
center
|
(Int, float, None or Parameter)
|
Peak center. |
None
|
width
|
(Int, float or Parameter)
|
|
1.0
|
unit
|
str or Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str
|
Display name of the component. |
'Lorentzian'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 Lorentzian evaluates to area*width / (pi * ( (x - center)^2 + width^2 ) )
Source code in src/easydynamics/sample_model/components/lorentzian.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
width
property
writable
Get the width parameter.
Polynomial
Bases: ModelComponent
Polynomial function component. c0 + c1x + c2x^2 + ... + cN*x^N.
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
|
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 | |
coefficient_values()
Get the coefficients of the polynomial as a list.
Source code in src/easydynamics/sample_model/components/polynomial.py
97 98 99 100 | |
coefficients
property
writable
Get the coefficients of the polynomial as a list of Parameters.
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 |
Source code in src/easydynamics/sample_model/components/polynomial.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
degree
property
writable
Return the degree of the polynomial.
evaluate(x)
Evaluate the Polynomial at the given x values.
The Polynomial evaluates to c0 + c1x + c2x^2 + ... + cN*x^N
Source code in src/easydynamics/sample_model/components/polynomial.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
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
134 135 136 137 138 139 140 | |
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int or float
|
Total area under the curve. |
1.0
|
center
|
Int or float or None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int or float
|
Standard deviation of the |
1.0
|
lorentzian_width
|
Int or float
|
Half width at half max (HWHM) |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str
|
Display name of the component. |
'Voigt'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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.
Source code in src/easydynamics/sample_model/components/voigt.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
gaussian_width
property
writable
Get the width parameter.
lorentzian_width
property
writable
Get the width parameter.
background_model
BackgroundModel
Bases: ModelBase
BackgroundModel represents a model of the background in an experiment at various Q.
Parameters
display_name : str Display name of the model. unique_name : str | None Unique name of the model. If None, a unique name will be generated. unit : str | sc.Unit | None Unit of the model. If None, unitless. 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. Q : Q_type | None Q values for the model. If None, Q is not set.
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 | |
component_collection
ComponentCollection
Bases: ModelBase
A model of the scattering from a sample, combining multiple model components.
Attributes
display_name : str Display name of the ComponentCollection. unit : str or sc.Unit Unit of the ComponentCollection.
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 | |
__contains__(item)
Check if a component with the given name or instance exists in the ComponentCollection.
Args:
item : str or ModelComponent The component name or instance to check for. Returns
bool True if the component exists, False otherwise.
Source code in src/easydynamics/sample_model/component_collection.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
__init__(unit='meV', display_name='MyComponentCollection', unique_name=None, components=None)
Initialize a new ComponentCollection.
Parameters
unit : str or sc.Unit, optional Unit of the sample model. Defaults to "meV". display_name : str Display name of the sample model. unique_name : str or None, optional Unique name of the sample model. Defaults to None. components : List[ModelComponent], optional Initial model components to add to the ComponentCollection.
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
__repr__()
Return a string representation of the ComponentCollection.
Returns
str
Source code in src/easydynamics/sample_model/component_collection.py
299 300 301 302 303 304 305 306 307 308 | |
clear_components()
Remove all components.
Source code in src/easydynamics/sample_model/component_collection.py
130 131 132 | |
convert_unit(unit)
Convert the unit of the ComponentCollection and all its components.
Source code in src/easydynamics/sample_model/component_collection.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
evaluate(x)
Evaluate the sum of all components.
Parameters
x : Number, list, np.ndarray, sc.Variable, or sc.DataArray Energy axis.
Returns
np.ndarray Evaluated model values.
Source code in src/easydynamics/sample_model/component_collection.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
evaluate_component(x, unique_name)
Evaluate a single component by name.
Parameters
x : Number, list, np.ndarray, sc.Variable, or sc.DataArray Energy axis. unique_name : str Component unique name.
Returns
np.ndarray Evaluated values for the specified component.
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
fix_all_parameters()
Fix all free parameters in the model.
Source code in src/easydynamics/sample_model/component_collection.py
266 267 268 269 | |
free_all_parameters()
Free all fixed parameters in the model.
Source code in src/easydynamics/sample_model/component_collection.py
271 272 273 274 | |
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/component_collection.py
163 164 165 166 167 168 169 170 | |
list_component_names()
List the names of all components in the model.
Returns
List[str] Component names.
Source code in src/easydynamics/sample_model/component_collection.py
119 120 121 122 123 124 125 126 127 128 | |
normalize_area()
Normalize the areas of all components so they sum to 1.
Source code in src/easydynamics/sample_model/component_collection.py
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 | |
unit
property
writable
Get the unit of the ComponentCollection.
Returns
str or sc.Unit or None
components
DampedHarmonicOscillator
Bases: CreateParametersMixin, ModelComponent
Damped Harmonic Oscillator (DHO). 2areacenter^2width/pi / ( (x^2 - center^2)^2 + (2width*x)^2 )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the component. |
'DampedHarmonicOscillator'
|
center
|
Int or float
|
Resonance frequency, approximately the |
1.0
|
width
|
Int or float
|
Damping constant, approximately the |
1.0
|
area
|
Int or float
|
Area under the curve. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 DHO evaluates to 2areacenter^2width/pi / ((x^2 - center^2)^2 + (2width*x)^2)
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
width
property
writable
Get 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 in the ResolutionHandler. 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 or float or None
|
Center of the delta function. |
None
|
area
|
Int or float
|
Total area under the curve. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
display_name
|
str
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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.
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
Gaussian
Bases: CreateParametersMixin, ModelComponent
Gaussian function: area/(widthsqrt(2pi)) * exp(-0.5((x - center)/width)^2) 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 or Parameter)
|
Area of the Gaussian. |
1.0
|
center
|
(Int, float, None or Parameter)
|
Center of the Gaussian. |
None
|
width
|
(Int, float or Parameter)
|
Standard deviation. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
display_name
|
str
|
Name of the component. |
'Gaussian'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 Gaussian evaluates to area/(widthsqrt(2pi)) * exp(-0.5((x - center)/width)^2)
Source code in src/easydynamics/sample_model/components/gaussian.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
width
property
writable
Get the width parameter.
Lorentzian
Bases: CreateParametersMixin, ModelComponent
Lorentzian function: area*width / (pi * ( (x - center)^2 + width^2 ) ) 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 or Parameter)
|
Area of the Lorentzian. |
1.0
|
center
|
(Int, float, None or Parameter)
|
Peak center. |
None
|
width
|
(Int, float or Parameter)
|
|
1.0
|
unit
|
str or Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str
|
Display name of the component. |
'Lorentzian'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 Lorentzian evaluates to area*width / (pi * ( (x - center)^2 + width^2 ) )
Source code in src/easydynamics/sample_model/components/lorentzian.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
width
property
writable
Get the width parameter.
Polynomial
Bases: ModelComponent
Polynomial function component. c0 + c1x + c2x^2 + ... + cN*x^N.
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
|
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 | |
coefficient_values()
Get the coefficients of the polynomial as a list.
Source code in src/easydynamics/sample_model/components/polynomial.py
97 98 99 100 | |
coefficients
property
writable
Get the coefficients of the polynomial as a list of Parameters.
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 |
Source code in src/easydynamics/sample_model/components/polynomial.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
degree
property
writable
Return the degree of the polynomial.
evaluate(x)
Evaluate the Polynomial at the given x values.
The Polynomial evaluates to c0 + c1x + c2x^2 + ... + cN*x^N
Source code in src/easydynamics/sample_model/components/polynomial.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
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
134 135 136 137 138 139 140 | |
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int or float
|
Total area under the curve. |
1.0
|
center
|
Int or float or None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int or float
|
Standard deviation of the |
1.0
|
lorentzian_width
|
Int or float
|
Half width at half max (HWHM) |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str
|
Display name of the component. |
'Voigt'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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.
Source code in src/easydynamics/sample_model/components/voigt.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
gaussian_width
property
writable
Get the width parameter.
lorentzian_width
property
writable
Get the width parameter.
damped_harmonic_oscillator
DampedHarmonicOscillator
Bases: CreateParametersMixin, ModelComponent
Damped Harmonic Oscillator (DHO). 2areacenter^2width/pi / ( (x^2 - center^2)^2 + (2width*x)^2 )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
Display name of the component. |
'DampedHarmonicOscillator'
|
center
|
Int or float
|
Resonance frequency, approximately the |
1.0
|
width
|
Int or float
|
Damping constant, approximately the |
1.0
|
area
|
Int or float
|
Area under the curve. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 DHO evaluates to 2areacenter^2width/pi / ((x^2 - center^2)^2 + (2width*x)^2)
Source code in src/easydynamics/sample_model/components/damped_harmonic_oscillator.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
width
property
writable
Get 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 in the ResolutionHandler. 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 or float or None
|
Center of the delta function. |
None
|
area
|
Int or float
|
Total area under the curve. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
display_name
|
str
|
Name of the component. |
'DeltaFunction'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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.
Source code in src/easydynamics/sample_model/components/delta_function.py
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 | |
gaussian
Gaussian
Bases: CreateParametersMixin, ModelComponent
Gaussian function: area/(widthsqrt(2pi)) * exp(-0.5((x - center)/width)^2) 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 or Parameter)
|
Area of the Gaussian. |
1.0
|
center
|
(Int, float, None or Parameter)
|
Center of the Gaussian. |
None
|
width
|
(Int, float or Parameter)
|
Standard deviation. |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. |
'meV'
|
display_name
|
str
|
Name of the component. |
'Gaussian'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 Gaussian evaluates to area/(widthsqrt(2pi)) * exp(-0.5((x - center)/width)^2)
Source code in src/easydynamics/sample_model/components/gaussian.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
width
property
writable
Get the width parameter.
lorentzian
Lorentzian
Bases: CreateParametersMixin, ModelComponent
Lorentzian function: area*width / (pi * ( (x - center)^2 + width^2 ) ) 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 or Parameter)
|
Area of the Lorentzian. |
1.0
|
center
|
(Int, float, None or Parameter)
|
Peak center. |
None
|
width
|
(Int, float or Parameter)
|
|
1.0
|
unit
|
str or Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str
|
Display name of the component. |
'Lorentzian'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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 Lorentzian evaluates to area*width / (pi * ( (x - center)^2 + width^2 ) )
Source code in src/easydynamics/sample_model/components/lorentzian.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
width
property
writable
Get 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 | |
model_component
ModelComponent
Bases: ModelBase
Abstract base class for all model components.
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 | |
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
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
evaluate(x)
abstractmethod
Evaluate the model component at input x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Numeric | Variable
|
Input values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Evaluated function values. |
Source code in src/easydynamics/sample_model/components/model_component.py
153 154 155 156 157 158 159 160 161 162 163 | |
fix_all_parameters()
Fix all parameters in the model component.
Source code in src/easydynamics/sample_model/components/model_component.py
48 49 50 51 52 53 | |
free_all_parameters()
Free all parameters in the model component.
Source code in src/easydynamics/sample_model/components/model_component.py
55 56 57 58 | |
unit
property
writable
Get the unit.
:return: Unit as a string.
validate_unit(unit)
staticmethod
Raise TypeError if unit is not allowed (string or sc.Unit).
Source code in src/easydynamics/sample_model/components/model_component.py
120 121 122 123 124 125 126 127 128 | |
polynomial
Polynomial
Bases: ModelComponent
Polynomial function component. c0 + c1x + c2x^2 + ... + cN*x^N.
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
|
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 | |
coefficient_values()
Get the coefficients of the polynomial as a list.
Source code in src/easydynamics/sample_model/components/polynomial.py
97 98 99 100 | |
coefficients
property
writable
Get the coefficients of the polynomial as a list of Parameters.
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 |
Source code in src/easydynamics/sample_model/components/polynomial.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
degree
property
writable
Return the degree of the polynomial.
evaluate(x)
Evaluate the Polynomial at the given x values.
The Polynomial evaluates to c0 + c1x + c2x^2 + ... + cN*x^N
Source code in src/easydynamics/sample_model/components/polynomial.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
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
134 135 136 137 138 139 140 | |
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Int or float
|
Total area under the curve. |
1.0
|
center
|
Int or float or None
|
Center of the Voigt profile. |
None
|
gaussian_width
|
Int or float
|
Standard deviation of the |
1.0
|
lorentzian_width
|
Int or float
|
Half width at half max (HWHM) |
1.0
|
unit
|
str or Unit
|
Unit of the parameters. Defaults to "meV" |
'meV'
|
display_name
|
str
|
Display name of the component. |
'Voigt'
|
unique_name
|
str or None
|
Unique name of the component. |
None
|
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 | |
area
property
writable
Get the area parameter.
center
property
writable
Get 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.
Source code in src/easydynamics/sample_model/components/voigt.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
gaussian_width
property
writable
Get the width parameter.
lorentzian_width
property
writable
Get the 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
:math:DQ^2. Q is assumed to have units of 1/angstrom. Creates
ComponentCollections with Lorentzian components for given Q-values.
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
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 | |
__init__(display_name='BrownianTranslationalDiffusion', unique_name=None, unit='meV', scale=1.0, diffusion_coefficient=1.0, diffusion_unit='m**2/s')
Initialize a new BrownianTranslationalDiffusion model.
Parameters
display_name : str Display name of the diffusion model. unique_name : str or None Unique name of the diffusion model. If None, a unique name is automatically generated. unit : str or sc.Unit, optional Energy unit for the underlying Lorentzian components. Defaults to "meV". scale : float or Parameter, optional Scale factor for the diffusion model. diffusion_coefficient : float or Parameter, optional Diffusion coefficient D. If a number is provided, it is assumed to be in the unit given by diffusion_unit. Defaults to 1.0. diffusion_unit : str, optional Unit for the diffusion coefficient D. Default is m2/s. Options are 'meV*Å2' or 'm**2/s'
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
__repr__()
String representation of the BrownianTranslationalDiffusion model.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
319 320 321 322 323 324 325 326 | |
calculate_EISF(Q)
Calculate the Elastic Incoherent Structure Factor (EISF) for the Brownian translational diffusion model.
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
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 180 181 182 | |
calculate_QISF(Q)
Calculate the Quasi-Elastic Incoherent Structure Factor (QISF).
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
np.ndarray QISF values (dimensionless).
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
calculate_width(Q)
Calculate the half-width at half-maximum (HWHM) for the diffusion model.
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
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
143 144 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.
Args:
Q : Number, list, or np.ndarray Scattering vector values. component_display_name : str Name of the Lorentzian component. Returns
List[ComponentCollection] List of ComponentCollections with Lorentzian components.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
diffusion_coefficient
property
writable
Get the diffusion coefficient parameter D.
Returns
Parameter Diffusion coefficient D.
scale
property
writable
Get the scale parameter of the diffusion model.
Returns
Parameter Scale parameter.
DiffusionModelBase
Bases: ModelBase
Base class for constructing diffusion models.
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_model_base.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 | |
__init__(display_name='MyDiffusionModel', unique_name=None, unit='meV')
Initialize a new DiffusionModel.
Parameters
display_name : str Display name of the diffusion model. unit : str or sc.Unit, optional Unit of the diffusion model. Defaults to "meV".
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_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 | |
__repr__()
String representation of the Diffusion model.
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_model_base.py
65 66 67 | |
unit
property
writable
Get the unit of the DiffusionModel.
Returns
str or sc.Unit or None
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
:math:DQ^2. Q is assumed to have units of 1/angstrom. Creates
ComponentCollections with Lorentzian components for given Q-values.
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
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 | |
__init__(display_name='BrownianTranslationalDiffusion', unique_name=None, unit='meV', scale=1.0, diffusion_coefficient=1.0, diffusion_unit='m**2/s')
Initialize a new BrownianTranslationalDiffusion model.
Parameters
display_name : str Display name of the diffusion model. unique_name : str or None Unique name of the diffusion model. If None, a unique name is automatically generated. unit : str or sc.Unit, optional Energy unit for the underlying Lorentzian components. Defaults to "meV". scale : float or Parameter, optional Scale factor for the diffusion model. diffusion_coefficient : float or Parameter, optional Diffusion coefficient D. If a number is provided, it is assumed to be in the unit given by diffusion_unit. Defaults to 1.0. diffusion_unit : str, optional Unit for the diffusion coefficient D. Default is m2/s. Options are 'meV*Å2' or 'm**2/s'
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
__repr__()
String representation of the BrownianTranslationalDiffusion model.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
319 320 321 322 323 324 325 326 | |
calculate_EISF(Q)
Calculate the Elastic Incoherent Structure Factor (EISF) for the Brownian translational diffusion model.
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
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 180 181 182 | |
calculate_QISF(Q)
Calculate the Quasi-Elastic Incoherent Structure Factor (QISF).
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
np.ndarray QISF values (dimensionless).
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
calculate_width(Q)
Calculate the half-width at half-maximum (HWHM) for the diffusion model.
Parameters
Q : np.ndarray | Numeric | list | ArrayLike Scattering vector in 1/angstrom
Returns
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
143 144 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.
Args:
Q : Number, list, or np.ndarray Scattering vector values. component_display_name : str Name of the Lorentzian component. Returns
List[ComponentCollection] List of ComponentCollections with Lorentzian components.
Source code in src/easydynamics/sample_model/diffusion_model/brownian_translational_diffusion.py
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 | |
diffusion_coefficient
property
writable
Get the diffusion coefficient parameter D.
Returns
Parameter Diffusion coefficient D.
scale
property
writable
Get the scale parameter of the diffusion model.
Returns
Parameter Scale parameter.
diffusion_model_base
DiffusionModelBase
Bases: ModelBase
Base class for constructing diffusion models.
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_model_base.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 | |
__init__(display_name='MyDiffusionModel', unique_name=None, unit='meV')
Initialize a new DiffusionModel.
Parameters
display_name : str Display name of the diffusion model. unit : str or sc.Unit, optional Unit of the diffusion model. Defaults to "meV".
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_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 | |
__repr__()
String representation of the Diffusion model.
Source code in src/easydynamics/sample_model/diffusion_model/diffusion_model_base.py
65 66 67 | |
unit
property
writable
Get the unit of the DiffusionModel.
Returns
str or sc.Unit or None
model_base
ModelBase
Bases: ModelBase
Base class for Sample Models.
Contains common functionality for models with components and Q dependence.
Parameters
display_name : str Display name of the model. unique_name : str | None Unique name of the model. If None, a unique name will be generated. unit : str | sc.Unit | None Unit of the model. If None, unitless. 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. Q : Q_type | None Q values for the model. If None, Q is not set.
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 | |
Q
property
writable
Get the Q values of the SampleModel.
append_component(component)
Append a ModelComponent or ComponentCollection to the SampleModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ModelComponent | ComponentCollection
|
|
required |
Source code in src/easydynamics/sample_model/model_base.py
100 101 102 103 104 105 106 107 108 109 | |
clear_components()
Clear all ModelComponents from the SampleModel.
Source code in src/easydynamics/sample_model/model_base.py
122 123 124 125 | |
components
property
writable
Get the components of the SampleModel.
convert_unit(unit)
Convert the unit of the ComponentCollection and all its components.
Source code in src/easydynamics/sample_model/model_base.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
evaluate(x)
Evaluate the sample model at all Q for the given x values.
Parameters
x : Number, list, np.ndarray, sc.Variable, or sc.DataArray Energy axis.
Returns
list[np.ndarray] Evaluated model values.
Source code in src/easydynamics/sample_model/model_base.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
get_all_variables()
Get all Parameters and Descriptors from all ComponentCollections in the ModelBase.
Ignores the Parameters and Descriptors in self._components as these are just templates.
Source code in src/easydynamics/sample_model/model_base.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
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 |
required |
Source code in src/easydynamics/sample_model/model_base.py
111 112 113 114 115 116 117 118 119 120 | |
unit
property
writable
Get the unit of the ComponentCollection.
Returns
str or sc.Unit or None
resolution_model
ResolutionModel
Bases: ModelBase
ResolutionModel represents a model of the instrment resolution in an experiment at various Q.
Parameters
display_name : str Display name of the model. unique_name : str | None Unique name of the model. If None, a unique name will be generated. unit : str | sc.Unit | None Unit of the model. If None, unitless. 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. Q : Number, list, np.ndarray or sc.Variable | None Q values for the model. If None, Q is not set.
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 | |
append_component(component)
Append a component to the ResolutionModel.
Does not allow DeltaFunction or Polynomial components, as these are not physical resolution components. Args: component (ModelComponent | ComponentCollection): Component(s) to append. Raises: TypeError: If the component is a DeltaFunction or Polynomial
Source code in src/easydynamics/sample_model/resolution_model.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
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
display_name : str Display name of the model. unique_name : str | None Unique name of the model. If None, a unique name will be generated. unit : str | sc.Unit | None Unit of the model. If None, unitless. 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. Q : Number, list, np.ndarray or sc.array or None. Q values for the model. If None, Q is not set. diffusion_models : DiffusionModelBase | list[DiffusionModelBase] | None Diffusion models to include in the SampleModel. If None, no diffusion models are added temperature : float | None Temperature for detailed balancing. If None, no detailed balancing is applied. temperature_unit : str | sc.Unit Unit of the temperature. Defaults to "K". divide_by_temperature : bool Whether to divide the detailed balance factor by temperature. Defaults to True.
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 | |
append_diffusion_model(diffusion_model)
Append a DiffusionModel to the SampleModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diffusion_model
|
DiffusionModelBase
|
The DiffusionModel |
required |
Source code in src/easydynamics/sample_model/sample_model.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
clear_diffusion_models()
Clear all DiffusionModels from the SampleModel.
Source code in src/easydynamics/sample_model/sample_model.py
145 146 147 148 | |
convert_temperature_unit(unit)
Convert the unit of the temperature Parameter.
Source code in src/easydynamics/sample_model/sample_model.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
diffusion_models
property
writable
Get the diffusion models of the SampleModel.
divide_by_temperature
property
writable
Get whether to divide the detailed balance factor by temperature.
evaluate(x)
Evaluate the sample model at all Q for the given x values.
Parameters
x : Number, list, np.ndarray, sc.Variable, or sc.DataArray Energy axis.
Returns
list[np.ndarray] List of evaluated model values for each Q.
Source code in src/easydynamics/sample_model/sample_model.py
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 | |
get_all_variables()
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.
Source code in src/easydynamics/sample_model/sample_model.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
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 |
Source code in src/easydynamics/sample_model/sample_model.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
temperature
property
writable
Get the temperature of the SampleModel.
temperature_unit
property
writable
Get the temperature unit of the SampleModel.