# Functional form¶

This notebook demonstrates the use of the FunctionalForm model to describe an exponential increase/decay from one layer to the next. The code in functional.py can be used as a starting point to change the exponential profile to a different analytic form.

In [1]:
# necessary imports
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt

from refnx.reflect import Slab, SLD, Structure
from functional import FunctionalForm

In [2]:
# some materials
si = SLD(2.07, 'Si')
poly1 = SLD(2.0, 'poly1')
poly2 = SLD(4.0, 'poly2')
d2o = SLD(6.36, 'd2o')

# increase from one to the other
poly1_l = poly1(100., 3.)
poly2_l = poly2(100., 3.)

ff = FunctionalForm(200., 30., 5., poly1_l, poly2_l)

struct = si | poly1_l| poly2_l | d2o(0, 3)
struct2 = si | poly1_l | ff | poly2_l | d2o(0, 3)

struct2.contract = 1.

plt.plot(*struct.sld_profile())
plt.plot(*struct2.sld_profile());

In [3]:
si = SLD(2.07, 'Si')
poly1 = SLD(4.0, 'poly1')
poly2 = SLD(2.0, 'poly2')
d2o = SLD(6.36, 'd2o')

# decay from one to the other
poly1_l = poly1(100., 3.)
poly2_l = poly2(100., 3.)

ff = FunctionalForm(200., 30., 3., poly1_l, poly2_l)

struct = si | poly1_l| poly2_l | d2o(0, 3)
struct2 = si | poly1_l | ff | poly2_l | d2o(0, 3)

struct2.contract = 1.

plt.plot(*struct.sld_profile())
plt.plot(*struct2.sld_profile());

In [4]:
si = SLD(2.07, 'Si')
poly1 = SLD(3.0, 'poly1')
d2o = SLD(6.36, 'd2o')

In [5]:
# decay to backing solvent
poly1_l = poly1(100., 3.)
d2o_l = d2o(0, 3)

ff = FunctionalForm(200., 30., 5., poly1_l, d2o_l)

struct = si | poly1_l | d2o(0, 3)
struct2 = si | poly1_l | ff | d2o_l

struct2.contract = 1.

plt.plot(*struct.sld_profile())
plt.plot(*struct2.sld_profile());

In [6]:
# use of the reverse keyword reverses the slab representation of
# this specific component
si = SLD(2.07, 'Si')
poly1 = SLD(1.0, 'poly1')
poly2 = SLD(4.0, 'poly2')
d2o = SLD(6.36, 'd2o')

# decay from one to the other
poly1_l = poly1(100., 3.)
poly2_l = poly2(100., 3.)

ff = FunctionalForm(200., 30., 3., poly1_l, poly2_l, reverse=True)

struct = si | poly1_l| poly2_l | d2o(0, 3)
struct2 = si | poly1_l | ff | poly2_l | d2o(0, 3)

struct2.contract = 1.

plt.plot(*struct.sld_profile())
plt.plot(*struct2.sld_profile());

In [8]:
# use of the reverse keyword reverses the slab representation of
# this specific component
si = SLD(2.07, 'Si')
poly1 = SLD(4.0, 'poly1')
poly2 = SLD(1.5, 'poly2')
d2o = SLD(6.36, 'd2o')

# decay from one to the other
poly1_l = poly1(100., 3.)
poly2_l = poly2(100., 3.)

ff = FunctionalForm(200., 30., 3., poly1_l, poly2_l, reverse=True)

struct = si | poly1_l| poly2_l | d2o(0, 3)
struct2 = si | poly1_l | ff | poly2_l | d2o(0, 3)

struct2.contract = 1.

plt.plot(*struct.sld_profile())
plt.plot(*struct2.sld_profile());

In [ ]: