Skip to content
Merged
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
15 changes: 11 additions & 4 deletions hogben/models/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from hogben.simulate import simulate, refl1d_experiment, reflectivity
from hogben.utils import fisher, Sampler, save_plot
from hogben.models.base import BaseSample
from refnx.analysis import Parameter

plt.rcParams['figure.figsize'] = (9, 7)
plt.rcParams['figure.dpi'] = 600
Expand Down Expand Up @@ -252,12 +253,14 @@ def to_refl1d(self):
# Iterate over each component.
structure = refl1d.material.SLD(rho=0, name='Air')
for component in self.structure[1:]:
name, sld = component.name, component.sld.real.value,
name = component.name
sld, sld_imag = component.sld.real.value, component.sld.imag.value
thick, rough = component.thick.value, component.rough.value

# Add the component in the opposite direction to the refnx
# definition.
layer = refl1d.material.SLD(rho=sld, name=name)(thick, rough)
layer = refl1d.material.SLD(rho=sld, irho=sld_imag, name=name)(
thick, rough)
structure = layer | structure

# Update the current structure to use the new version.
Expand All @@ -272,12 +275,16 @@ def to_refnx(self):
# Iterate over each component.
structure = refnx.reflect.SLD(0, name='Air')
for component in list(reversed(self.structure))[1:]:
name, sld = component.name, component.material.rho.value,
name = component.name
sld, sld_imag = \
Parameter(component.material.rho.value), \
Parameter(component.material.irho.value)
thick, rough = component.thickness.value, component.interface.value

# Add the component in the opposite direction to the Refl1D
# definition.
structure |= refnx.reflect.SLD(sld, name=name)(thick, rough)
structure |= refnx.reflect.SLD([sld, sld_imag], name=name)(
thick, rough)

# Update the current structure to use the new version.
structure.name = self.structure.name
Expand Down