Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
History
=======

1.2.3 (2026-03-16)
------------------
* Add ContentHash class for file consistencey validation option in header
* Improve the documentation, thanks to alexhroom (#133)
* Switch SLDdb webapi url to new website https://slddb.reflectometry.org
* Fix export of classes with default parameters to not write the default values to YAML (#149)
* Fix some issues with build and tests on github

1.2.2 (2025-06-27)
------------------

Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ include LICENSE
include README.rst

recursive-include tests *
recursive-include orsopy/slddb/element_table/nabs_geant4_data *.npz
recursive-include orsopy/fileio/schema/ *.json
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
Expand Down
4 changes: 4 additions & 0 deletions examples/sample_model_complex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ sample:
composition:
copper: 0.5
Si: 0.5
test:
stacks: 7
blocks: 54
layers: 253
4 changes: 4 additions & 0 deletions examples/sample_model_example_1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ sample:
model:
origin: guess based on preparation
stack: air | 10 ( Si 7 | Fe 7 ) | Si
test:
stacks: 3
blocks: 22
layers: 22
4 changes: 4 additions & 0 deletions examples/sample_model_example_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ sample:
roughness: {magnitude: 5.0, unit: angstrom}
sld_unit: 1/angstrom^2
reference: ORSO model language | 1.0 | http://bla.bli
test:
stacks: 3
blocks: 22
layers: 22
6 changes: 5 additions & 1 deletion examples/sample_model_example_3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ sample:
length_unit: angstrom
mass_density_unit: g/cm^3
sld_unit: 1/angstrom^2
reference: ORSO model language | 1.0 | https://www.reflectometry.org/projects/simple_model
reference: ORSO model language | 1.0 | https://www.reflectometry.org/projects/simple_model
test:
stacks: 3
blocks: 23
layers: 23
58 changes: 36 additions & 22 deletions examples/sample_model_example_4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,43 @@ sample:
stack: Si | LL | rLL | solvent
sub_stacks:
LL:
sub_stack_class: LipidLeaflet
apm: 56.0
b_heads: 6.01e-4
vm_heads: 319.0
b_tails: -2.92e-4
vm_tails: 782.0
thickness_heads: 9.0
head_solvent: solvent
tail_solvent: solvent
thickness: 23.0
comment: Shows the equivalence of using Value or float for apm/vm_heads/vm_tails
sequence:
- material: {sld: 1.88401254e-06}
thickness: 9.0
roughness: 3.0
- material: {sld: -3.73401535e-07}
thickness: 1.4
roughness: 3.0
#sub_stack_class: LipidLeaflet - not yet introduced in API
#apm: 56.0
#b_heads: 6.01e-4
#vm_heads: 319.0
#b_tails: -2.92e-4
#vm_tails: 782.0
#thickness_heads: 9.0
#head_solvent: solvent
#tail_solvent: solvent
#thickness: 23.0
#comment: Shows the equivalence of using Value or float for apm/vm_heads/vm_tails
rLL:
sub_stack_class: LipidLeaflet
apm: {magnitude: 56.0, unit: Angstrom^2}
b_heads: 6.01e-4
vm_heads: {magnitude: 319.0, unit: Angstrom^3}
b_tails: -2.92e-4
vm_tails: {magnitude: 782.0, unit: Angstrom^3}
thickness_heads: 9.0
head_solvent: solvent
tail_solvent: solvent
thickness: 23.0
reverse_monolayer: true
sequence:
- material: {sld: -3.73401535e-07}
thickness: 1.4
roughness: 0.0
- material: {sld: 1.88401254e-06}
thickness: 9.0
roughness: 3.0
#sub_stack_class: LipidLeaflet
#apm: {magnitude: 56.0, unit: Angstrom^2}
#b_heads: 6.01e-4
#vm_heads: {magnitude: 319.0, unit: Angstrom^3}
#b_tails: -2.92e-4
#vm_tails: {magnitude: 782.0, unit: Angstrom^3}
#thickness_heads: 9.0
#head_solvent: solvent
#tail_solvent: solvent
#thickness: 23.0
#reverse_monolayer: true
composits:
solvent:
composition:
Expand Down
6 changes: 5 additions & 1 deletion examples/sample_model_example_5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ sample:
Fe:
magnetic_moment: 2.5
Si:
relative_density: 0.9
relative_density: 0.9
test:
stacks: 3
blocks: 22
layers: 22
6 changes: 5 additions & 1 deletion examples/sample_model_example_6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ sample:
but:
roughness: 15.0
globals:
slice_resolution: {magnitude: 10.0, unit: nm}
slice_resolution: {magnitude: 10.0, unit: nm}
test:
stacks: 4
blocks: 13
layers: 57
4 changes: 4 additions & 0 deletions examples/sample_model_example_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ sample:
material1: Ni
material2: Ti
function: 0.5+0.5*sin(x*2*pi)
test:
stacks: 3
blocks: 7
layers: 52
4 changes: 4 additions & 0 deletions examples/sample_model_example_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ sample:
material1: Ni
material2: Ti
function: (0.5+0.5*sin(x*20.0*2*pi))*exp(-(x-0.5)**2/0.25**2)
test:
stacks: 3
blocks: 3
layers: 202
14 changes: 14 additions & 0 deletions examples/sample_model_example_9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sample:
model:
comment: Material from SLD db Bio Blender mixture
stack: air | dna1 50 | RNA=AUGUUUAGUUAA 50 | protein1 100 | Si
layers:
dna1:
material: DNA=ATTAG
protein1:
material: Protein=MAHAGRTGYDNREIVMKYIHYKLSQRGYEWDAGDVGAAPPGAAPAPGIFSSQPGHTPHPAASRDPVARTSPLQTPAAPGAAAGPALSPVPPVVHLTLRQAGDDFSRRYRRDFAEMSSQLHLTPFTARGRFATVVEELFRDGVNWGRIVAFFEFGGVMCVESVNREMSPLVDNIALWMTEYLNRHLHTWIQDNGGWDAFVELYGPSMRPLFDFSWLSLKTLLSLALVGACITLGAYLGHK
comment: Bcl-2
test:
stacks: 5
blocks: 5
layers: 5
43 changes: 28 additions & 15 deletions examples/sample_model_export_genx.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
stack: ambient | top | ML | buffer | substrate
stack: Amb | top | ML | buffer | Sub
origin: GenX model "X-ray_Reflectivity.hgx"
sub_stacks:
top:
Expand All @@ -11,45 +11,58 @@ sub_stacks:
repetitions: 1
stack: bufPt | bufFe
layers:
Amb:
material:
sld: {real: 1.0e-25, imag: 1.0e-25, unit: 1/angstrom^2}
topPt:
thickness: 11.0
roughness: 3.0
material:
sld: {real: 4.864311704082625e-06, imag: -4.533346598101179e-07}
formula: Pt
number_density: 0.06640515431495381
TopFe:
thickness: 11.0
roughness: 2.0
material:
sld: {real: 2.1041406836134337e-06, imag: -2.7004929545359514e-07}
formula: Fe
number_density: 0.08495744391749196
Pt:
thickness: 11.0
thickness: 18.0
roughness: 2.0
material:
sld: {real: 4.864311704082625e-06, imag: -4.533346598101179e-07}
formula: Pt
number_density: 0.06640515431495381
Fe:
thickness: 11.0
roughness: 2.0
material:
sld: {real: 2.1041406836134337e-06, imag: -2.7004929545359514e-07}
formula: Fe
number_density: 0.08495744391749196
bufPt:
thickness: 45.0
roughness: 2.0
material:
sld: {real: 4.864311704082625e-06, imag: -4.533346598101179e-07}
formula: Pt
number_density: 0.06640515431495381
bufFe:
thickness: 2.0
roughness: 2.0
material:
sld: {real: 2.1041406836134337e-06, imag: -2.7004929545359514e-07}
materials:
ambient:
sld: {real: 9.999999999999999e-27, imag: 9.999999999999999e-27}
substrate:
sld: {real: 5.456591989186995e-07, imag: -5.636808187886301e-09}
formula: Fe
number_density: 0.08495744391749196
Sub:
roughness: 4.0
material:
formula: MgO
number_density: 0.026994924954108625
globals:
roughness: {magnitude: 0.3, unit: nm}
length_unit: angstrom
mass_density_unit: g/cm^3
number_density_unit: 1/nm^3
number_density_unit: 1/angstrom^3
sld_unit: 1/angstrom^2
magnetic_moment_unit: muB
test:
stacks: 5
# 1 + 2 + 19*2 + 2 + 1 = 44
blocks: 44
layers: 44
2 changes: 1 addition & 1 deletion orsopy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Top-level package for orsopy."""

__version__ = "1.2.2"
__version__ = "1.2.3"
28 changes: 25 additions & 3 deletions orsopy/fileio/model_building_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Union

from ..utils.chemical_formula import Formula
from slddb.chemical_formula import Formula
from ..utils.density_resolver import MaterialResolver
from .base import ComplexValue, Header, Value

Expand Down Expand Up @@ -122,7 +122,7 @@ def get_sld(self, xray_energy=None) -> complex:
if self.sld is not None:
return rel * self.sld.as_unit("1/angstrom^2") + 0j

from orsopy.slddb.material import Material, get_element
from slddb.material import Material, get_element

formula = Formula(self.formula, strict=True)
if self.mass_density is not None:
Expand Down Expand Up @@ -247,7 +247,29 @@ def resolve_names(self, resolvable_items):
elif self.material in SPECIAL_MATERIALS:
self.material = SPECIAL_MATERIALS[self.material]
else:
self.material = Material(formula=self.material)
try:
Formula(self.material, strict=True)
except ValueError:
# try to resolve name directly with databse
res = None
if len(DENSITY_RESOLVERS) == 0:
from ..utils.resolver_slddb import ResolverSLDDB

DENSITY_RESOLVERS.append(ResolverSLDDB())
for resolver in DENSITY_RESOLVERS:
res = resolver.resolve_item(self.material)
if res is not None:
break
if res:
# could resolve the string to an actual material
self.material = Material(
formula=res["formula"], number_density=res["number_density"], comment=res["comment"]
)
else:
# will lead to errors later but keep string as formula
self.material = Material(formula=self.material)
else:
self.material = Material(formula=self.material)
elif self.composition is not None:
self._composition_materials = {}
for key, value in self.composition.items():
Expand Down
10 changes: 7 additions & 3 deletions orsopy/fileio/model_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dataclasses import dataclass
from typing import Dict, List, Optional, Union

from ..utils.chemical_formula import Formula
from slddb.chemical_formula import Formula
from . import model_complex
from .base import Header, Literal
from .model_building_blocks import (DENSITY_RESOLVERS, SPECIAL_MATERIALS, Composit, Layer, Material, ModelParameters,
Expand Down Expand Up @@ -169,7 +169,7 @@ def resolve_to_blocks(self) -> List[Union[Layer, SubStackType]]:
sub_blocks = obj.resolve_to_blocks()
blocks = blocks[: i + added] + sub_blocks + blocks[i + added :]
added += len(sub_blocks) - 1
return blocks
return blocks * self.repetitions

def resolve_to_layers(self) -> List[Layer]:
layers = list(self.sequence)
Expand Down Expand Up @@ -304,6 +304,10 @@ def resolve_stack(self):
except ValueError:
# try to resolve name directly with databse
res = None
if len(DENSITY_RESOLVERS) == 0:
from ..utils.resolver_slddb import ResolverSLDDB

DENSITY_RESOLVERS.append(ResolverSLDDB())
for resolver in DENSITY_RESOLVERS:
res = resolver.resolve_item(item)
if res is not None:
Expand Down Expand Up @@ -336,7 +340,7 @@ def resolve_stack(self):
return output

def resolve_to_blocks(self) -> List[Union[Layer, SubStackType]]:
# like resovle_to_layers but keeping SubStackType classes in tact
# like resovle_to_layers but keeping SubStackType classes intact
blocks = self.resolve_stack()
added = 0
for i in range(len(blocks)):
Expand Down
Loading
Loading