-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
358 lines (246 loc) · 11.8 KB
/
app.py
File metadata and controls
358 lines (246 loc) · 11.8 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objects as go
import numpy as np
import lennard_jones as lj
import header
import introduction as intro
import force_fields as ff
import bonds as bond
import angles as angle
import coulomb as coul
import references as ref
import plotly.express as px
app = dash.Dash(__name__,external_stylesheets=[dbc.themes.GRID])
# server = app.server
#
# app.scripts.config.serve_locally = True
# app.css.config.serve_locally = True
app.layout = html.Div([
### HEADER ###
header.header_text,
# ### INTRODUCTION ###
# html.Div([intro.intro_text], className='float'),
### FORCE FIELDS ###
html.Div([ff.ff_text], className='float'),
### BOND POTENTIAL ###
html.Div([
bond.bond_text,
html.Br(),
], className='float'),
html.Div([
html.Div([
html.Div([
html.Div([
html.Div(['b (\u212B)'], className = 'col-sm-3', style={'textAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
bond.bond_b_slider,
], className = 'col-sm-9', style={'verticalAlign':'center'}),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Label(['b', html.Sub('o'), ' (\u212B)'], className = 'col-sm-3', style={'textAlign':'center', 'verticalAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
bond.bond_bo_slider,
], className = 'col-sm-9'),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Label(['K', html.Sub('b'),' (kJ/(mol*\u212B',html.Sup('2'),'))'], className = 'col-sm-3', style={'textAlign':'center', 'verticalAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
bond.bond_kb_slider,
], className = 'col-sm-9'),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
], className = 'float', style={'verticalAlign':'center'}),
html.Div([
bond.bond_force_plot,
], className = 'float', style={'height':'290px'}),
], className='col-sm-6'),
html.Div([
html.Div([
bond.bond_plot,
], className = 'float', style={}),
], className='col-sm-6'),
], className='row'),
### ANGLE POTENTIAL ###
html.Div([
angle.angle_text,
html.Br(),
], className='float'),
html.Div([
html.Div([
html.Div([
html.Div([
html.Div(['\u03B8 (degrees)'], className = 'col-sm-4', style={'textAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
angle.angle_th_slider,
], className = 'col-sm-8', style={'verticalAlign':'center'}),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Label(['\u03B8', html.Sub('o'), ' (degrees)'], className = 'col-sm-4', style={'textAlign':'center', 'verticalAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
angle.angle_tho_slider,
], className = 'col-sm-8'),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Label(['K', html.Sub('\u03B8'),' (kJ/(mol*degrees',html.Sup('2'),'))'], className = 'col-sm-4', style={'textAlign':'center', 'verticalAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
angle.angle_kth_slider,
], className = 'col-sm-8'),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
], className = 'float', style={'verticalAlign':'center'}),
html.Div([
angle.angle_force_plot,
], className = 'float', style={'height':'290px'}),
], className='col-sm-6'),
html.Div([
html.Div([
angle.angle_plot,
], className = 'float', style={}),
], className='col-sm-6'),
], className='row'),
### LENNARD-JONES POTENTIAL ###
html.Div([
lj.lj_text,
html.Br(),
], className='float'),
html.Div([
html.Div([
html.Div([
html.Div([
html.Div(['r (\u212B)'], className = 'col-sm-3', style={'textAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
lj.lj_r_slider,
], className = 'col-sm-9', style={'verticalAlign':'center'}),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Label(['\u03C3 (\u212B)'], className = 'col-sm-3', style={'textAlign':'center', 'verticalAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
lj.lj_s_slider,
], className = 'col-sm-9'),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Label(['\u025B (kJ/mol)'], className = 'col-sm-3', style={'textAlign':'center', 'verticalAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
lj.lj_e_slider,
], className = 'col-sm-9'),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
], className = 'float', style={'verticalAlign':'center'}),
html.Div([
lj.lj_force_plot,
], className = 'float', style={'height':'290px'}),
], className='col-sm-6'),
html.Div([
html.Div([
lj.lj_plot,
], className = 'float', style={}),
], className='col-sm-6'),
], className='row'),
### COULOMB POTENTIAL ###
html.Div([
coul.coulomb_text,
html.Br(),
], className='float'),
html.Div([
html.Div([
html.Div([
html.Div([
html.Div(['q', html.Sub('1'),' (e)'], className = 'col-sm-3', style={'textAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
coul.coul_q1_slider,
], className = 'col-sm-9', style={'verticalAlign':'center'}),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Div(['q', html.Sub('2'),' (e)'], className = 'col-sm-3', style={'textAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
coul.coul_q2_slider,
], className = 'col-sm-9', style={'verticalAlign':'center'}),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Label(['r (\u212B)'], className = 'col-sm-3', style={'textAlign':'center', 'verticalAlign':'center', 'fontFamily':'serif', 'fontSize':'16px'}),
html.Div([
coul.coul_r_slider,
], className = 'col-sm-9'),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
html.Div([
html.Label(['\u03BA'], className = 'col-sm-3', style={'textAlign':'center', 'verticalAlign':'center', 'fontFamily':'sans-serif', 'fontSize':'16px'}),
html.Div([
coul.coul_k_slider,
], className = 'col-sm-9'),
], className = 'row', style={'verticalAlign':'center','height':'50px', 'padding': '15px 0'}),
], className = 'float', style={'verticalAlign':'center'}),
html.Div([
coul.coul_force_plot,
], className = 'float', style={'height':'240px'}),
], className='col-sm-6'),
html.Div([
html.Div([
coul.coul_plot,
], className = 'float', style={}),
], className='col-sm-6'),
], className='row'),
# ### REFERENCES ###
html.Div([ref.refs], className='float'),
])
### UPDATE LENNARD-JONES POTENTIAL PLOT ###
@app.callback(Output('lj_plot', 'figure'),
[Input('lj_e_slider', 'value'),
Input('lj_s_slider', 'value'),
Input('lj_r_slider', 'value')])
def update_lj_plot(e_value, s_value, r_value):
return lj.update_lj_plot(e_value, s_value, r_value)
### UPDATE LENNARD-JONES ATOM-FORCE PLOT ###
@app.callback(Output('lj_force_plot', 'figure'),
[Input('lj_e_slider', 'value'),
Input('lj_s_slider', 'value'),
Input('lj_r_slider', 'value')])
def update_lj_force_plot(e_value, s_value, r_value):
return lj.update_lj_force_plot(e_value, s_value, r_value)
### UPDATE COULOMB POTENTIAL PLOT ###
@app.callback(Output('coul_plot', 'figure'),
[Input('coul_q1_slider', 'value'),
Input('coul_q2_slider', 'value'),
Input('coul_r_slider', 'value'),
Input('coul_k_slider', 'value')])
def update_coul_plot(q1_value, q2_value, r_value, k_value):
return coul.update_coul_plot(q1_value, q2_value, r_value, k_value)
### UPDATE COULOMB ATOM-FORCE PLOT ###
@app.callback(Output('coul_force_plot', 'figure'),
[Input('coul_q1_slider', 'value'),
Input('coul_q2_slider', 'value'),
Input('coul_r_slider', 'value'),
Input('coul_k_slider', 'value')])
def update_coul_force_plot(q1_value, q2_value, r_value, k_value):
return coul.update_coul_force_plot(q1_value, q2_value, r_value, k_value)
### UPDATE BONDED POTENTIAL PLOT ###
@app.callback(Output('bond_plot', 'figure'),
[Input('bond_b_slider', 'value'),
Input('bond_bo_slider', 'value'),
Input('bond_kb_slider', 'value')])
def update_bond_plot(b_value, bo_value, kb_value):
return bond.update_bond_plot(b_value, bo_value, kb_value)
### UPDATE BONDED ATOM-FORCE PLOT ###
@app.callback(Output('bond_force_plot', 'figure'),
[Input('bond_b_slider', 'value'),
Input('bond_bo_slider', 'value'),
Input('bond_kb_slider', 'value')])
def update_bond_force_plot(b_value, bo_value, kb_value):
return bond.update_bond_force_plot(b_value, bo_value, kb_value)
### UPDATE ANGLE POTENTIAL PLOT ###
@app.callback(Output('angle_plot', 'figure'),
[Input('angle_th_slider', 'value'),
Input('angle_tho_slider', 'value'),
Input('angle_kth_slider', 'value')])
def update_angle_plot(th_value, tho_value, kth_value):
return angle.update_angle_plot(th_value, tho_value, kth_value)
### UPDATE ANGLE ATOM-FORCE PLOT ###
@app.callback(Output('angle_force_plot', 'figure'),
[Input('angle_th_slider', 'value'),
Input('angle_tho_slider', 'value'),
Input('angle_kth_slider', 'value')])
def update_angle_force_plot(th_value, tho_value, kth_value):
return angle.update_angle_force_plot(th_value, tho_value, kth_value)
# set debug=False when not in development
if __name__ == '__main__':
app.run_server(debug=True)