diff --git a/hogben/models/samples.py b/hogben/models/samples.py index d427f58e..0105c350 100644 --- a/hogben/models/samples.py +++ b/hogben/models/samples.py @@ -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 @@ -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. @@ -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