forked from RascalSoftware/python-RAT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSPC_custom_layers.py
More file actions
130 lines (103 loc) · 5.14 KB
/
DSPC_custom_layers.py
File metadata and controls
130 lines (103 loc) · 5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
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
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
"""Example of using custom layers to model a DSPC supported bilayer."""
import pathlib
import numpy as np
import RATapi as RAT
def DSPC_custom_layers():
"""Calculate a Custom Layers example for a supported DSPC layer."""
problem = RAT.Project(name="Orso lipid example - custom layers", model="custom layers", geometry="substrate/liquid")
# First we need to set up a parameters group. We will be using a pre-prepared custom model file, so we need to add
# the relevant parameters we are going to need to define the model (note that Substrate Roughness always exists as
# parameter 1).
problem.parameters.append(name="Oxide Thickness", min=5.0, value=20.0, max=60.0, fit=True)
problem.parameters.append(name="Oxide Hydration", min=0.0, value=0.2, max=0.5, fit=True)
problem.parameters.append(name="Lipid APM", min=45.0, value=55.0, max=65.0, fit=True)
problem.parameters.append(name="Head Hydration", min=0.0, value=0.2, max=0.5, fit=True)
problem.parameters.append(name="Bilayer Hydration", min=0.0, value=0.1, max=0.2, fit=True)
problem.parameters.append(name="Bilayer Roughness", min=2.0, value=4.0, max=8.0, fit=True)
problem.parameters.append(name="Water Thickness", min=0.0, value=2.0, max=10.0, fit=True)
problem.parameters.set_fields(0, min=1.0, max=10.0)
# Need to add the relevant Bulk SLDs. Change the bulk in from air to silicon, and add two additional water
# contrasts:
problem.bulk_in.set_fields(0, name="Silicon", min=2.07e-6, value=2.073e-6, max=2.08e-6, fit=False)
problem.bulk_out.append(name="SLD SMW", min=1.0e-6, value=2.073e-6, max=3.0e-6, fit=True)
problem.bulk_out.append(name="SLD H2O", min=-0.6e-6, value=-0.56e-6, max=-0.3e-6, fit=True)
problem.bulk_out.set_fields(0, min=5.0e-6, fit=True)
# Now add the datafiles. We have three datasets we need to consider - the bilayer against D2O, Silicon Matched
# Water and H2O. Load these datafiles in and put them in the data block
# Read in the datafiles
data_path = pathlib.Path(__file__).parents[1] / "data"
D2O_data = np.loadtxt(data_path / "c_PLP0016596.dat", delimiter=",")
SMW_data = np.loadtxt(data_path / "c_PLP0016601.dat", delimiter=",")
H2O_data = np.loadtxt(data_path / "c_PLP0016607.dat", delimiter=",")
# Add the data to the project - note this data has a resolution 4th column
problem.data.append(name="Bilayer / D2O", data=D2O_data, data_range=[0.013, 0.37])
problem.data.append(name="Bilayer / SMW", data=SMW_data, data_range=[0.013, 0.32996])
problem.data.append(name="Bilayer / H2O", data=H2O_data, data_range=[0.013, 0.33048])
# Add the custom file to the project
problem.custom_files.append(
name="DSPC Model",
filename="custom_bilayer_DSPC.py",
language="python",
path=pathlib.Path(__file__).parent,
)
# Also, add the relevant background parameters - one each for each contrast:
problem.background_parameters.set_fields(
0,
name="Background parameter D2O",
min=1.0e-10,
max=1.0e-5,
value=1.0e-07,
fit=True,
)
problem.background_parameters.append(
name="Background parameter SMW", min=1.0e-10, value=1.0e-7, max=1.0e-5, fit=True
)
problem.background_parameters.append(
name="Background parameter H2O", min=1.0e-10, value=1.0e-7, max=1.0e-5, fit=True
)
# And add the two new constant backgrounds
problem.backgrounds.append(name="Background SMW", type="constant", source="Background parameter SMW")
problem.backgrounds.append(name="Background H2O", type="constant", source="Background parameter H2O")
# And edit the other one
problem.backgrounds.set_fields(0, name="Background D2O", source="Background parameter D2O")
# Finally modify some of the other parameters to be more suitable values for a solid / liquid experiment
problem.scalefactors.set_fields(0, value=1.0, min=0.5, max=2.0, fit=True)
# Also, we are going to use the data resolution
problem.resolutions.append(name="Data Resolution", type="data")
# Now add the three contrasts
problem.contrasts.append(
name="Bilayer / D2O",
background="Background D2O",
resolution="Data Resolution",
scalefactor="Scalefactor 1",
bulk_out="SLD D2O",
bulk_in="Silicon",
data="Bilayer / D2O",
model=["DSPC Model"],
)
problem.contrasts.append(
name="Bilayer / SMW",
background="Background SMW",
resolution="Data Resolution",
scalefactor="Scalefactor 1",
bulk_out="SLD SMW",
bulk_in="Silicon",
data="Bilayer / SMW",
model=["DSPC Model"],
)
problem.contrasts.append(
name="Bilayer / H2O",
background="Background H2O",
resolution="Data Resolution",
scalefactor="Scalefactor 1",
bulk_out="SLD H2O",
bulk_in="Silicon",
data="Bilayer / H2O",
model=["DSPC Model"],
)
controls = RAT.Controls()
problem, results = RAT.run(problem, controls)
return problem, results
if __name__ == "__main__":
problem, results = DSPC_custom_layers()
RAT.plotting.plot_ref_sld(problem, results, True)