-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcosolidation.py
698 lines (617 loc) · 30.2 KB
/
cosolidation.py
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
import os
import dash
from dash import dcc, html
from dash.dependencies import Input, Output, State
import numpy as np
import plotly.graph_objs as go
import time
app = dash.Dash(__name__, meta_tags=[{"name": "viewport", "content": "width=device-width, initial-scale=1"}])
app.title = 'Consolidation'
app._favicon = ('assets/favicon.ico')
# Updated layout with sliders on top and layer properties below
app.layout = html.Div([
# Main container
html.Div(style={'display': 'flex', 'flexDirection': 'row', 'width': '100%', 'height': '100vh'}, children=[
# Control container (sliders)
html.Div(id='control-container', style={'width': '25%', 'padding': '2%', 'flexDirection': 'column'}, children=[
html.H1('Consolidation', className='h1'),
# Add the update button
html.Button("Update Graphs", id='update-button', n_clicks=0, style={'width': '100%', 'height': '5vh', 'marginBottom': '1vh'}),
# Sliders for each layer
html.Div(className='slider-container', children=[
# Sand-1 Slider
html.Label(children=[
'Z', html.Sub('1'), ' (m)',
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Thickness of Sand-1.', className='tooltiptext')
])], className='slider-label'),
dcc.Slider(
id='z-1', min=0, max=20, step=0.25, value=2,
marks={i: f'{i}' for i in range(0, 21, 5)},
className='slider', tooltip={'placement': 'bottom', 'always_visible': True}
),
# Clay Slider
html.Label(children=[
'Z', html.Sub('2'), ' (m)',
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Thickness of Clay.', className='tooltiptext')
])], className='slider-label'),
dcc.Slider(
id='z-2', min=0, max=20, step=0.25, value=4,
marks={i: f'{i}' for i in range(0, 21, 5)},
className='slider', tooltip={'placement': 'bottom', 'always_visible': True}
),
# Sand-2 Slider
html.Label(children=[
'Z', html.Sub('3'), ' (m)',
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Thickness of Sand-2.', className='tooltiptext')
])], className='slider-label'),
dcc.Slider(
id='z-3', min=0, max=20, step=0.25, value=2,
marks={i: f'{i}' for i in range(0, 21, 5)},
className='slider', tooltip={'placement': 'bottom', 'always_visible': True}
),
# Water table slider
html.Label(children=[
"Water Table",
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Water table depth from the surface.', className='tooltiptext')
])], className='slider-label'),
dcc.Slider(
id='water-table', min=0, max=4, step=0.25, value=0,
marks={i: f'{i}' for i in range(0, 5, 2)},
className='slider', tooltip={'placement': 'bottom', 'always_visible': True}
),
# time slider
html.Label(children=[
"Time",
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Time for consolidation.', className='tooltiptext')
])], className='slider-label'),
dcc.Slider(
id='time-slider', min=0, max=100, step=1, value=0,
marks={0: '0', 100: '∞'},
tooltip=None, updatemode='drag'
),
]),
# Properties for each layer
html.Div(className='layer-properties', children=[
# foundation Properties
html.H3('Load:', style={'textAlign': 'left'}, className='h3'),
html.Label(["Δσ",
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Chnage of stress', className='tooltiptext')
]),'(kPa)'], className='input-label'),
dcc.Input(id='delta_sigma', type='number', value=100, step=1, className='input-field'),
# Sand-1 Properties
html.H3('Sand-1:', style={'textAlign': 'left'}, className='h3'),
html.Label([f'γ', html.Sub('d'),
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Dry unit weight of Sand-1', className='tooltiptext')
]),' (kN/m³)'], className='input-label'),
dcc.Input(id='gamma_1', type='number', value=18, step=0.01, className='input-field'),
html.Label([f'γ', html.Sub('sat'),
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Saturated unit weight of Sand-1', className='tooltiptext')
]),' (kN/m³)'], className='input-label'),
dcc.Input(id='gamma_r_1', type='number', value=19, step=0.01, className='input-field'),
html.Div(style={'display': 'flex', 'alignItems': 'center', 'whiteSpace': 'nowrap'}, children=[
html.Label([f'γ′',
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Submerged unit weight of Sand-1', className='tooltiptext')
])], className='input-label', style={'marginRight': '5px'}),
html.Div(id='gamma_prime_1', className='input-field')
]),
# Clay Properties
html.H3('Clay:', style={'textAlign': 'left'}, className='h3'),
html.Label([f'γ', html.Sub('d'),
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Dry unit weight of Clay', className='tooltiptext')
]),' (kN/m³)'], className='input-label'),
dcc.Input(id='gamma_2', type='number', value=19, step=0.01, className='input-field'),
html.Label([f'γ', html.Sub('sat'),
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Saturated unit weight of Caly', className='tooltiptext')
]),' (kN/m³)'], className='input-label'),
dcc.Input(id='gamma_r_2', type='number', value=21, step=0.01, className='input-field'),
html.Div(style={'display': 'flex', 'alignItems': 'center', 'whiteSpace': 'nowrap'}, children=[
html.Label([f'γ′',
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Submerged unit weight of Clay', className='tooltiptext')
])], className='input-label', style={'marginRight': '5px'}),
html.Div(id='gamma_prime_2',className='input-field')
]),
html.Label([f'm', html.Sub('v'), ' (m²/kN)',
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Coefficient of compressibility of Clay', className='tooltiptext')
])], className='input-label'),
dcc.Input(id='m_v', type='number', value=5e-4, step=1e-5, className='input-field'),
html.Label(["k (m/s)",
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Coefficient of permeability of Clay', className='tooltiptext')
])], className='input-label'),
dcc.Input(id='k', type='number', value=1e-10, step=1e-10, className='input-field'),
# Sand-2 Properties
html.H3('Sand-2:', style={'textAlign': 'left'}, className='h3'),
html.Label([f'γ', html.Sub('d'),
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Dry unit weight of Sand-2', className='tooltiptext')
]),' (kN/m³)'], className='input-label'),
dcc.Input(id='gamma_3', type='number', value=18, step=0.01, className='input-field'),
html.Label([f'γ', html.Sub('sat'),
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Saturated unit weight of Sand-2', className='tooltiptext')
]),' (kN/m³)'], className='input-label'),
dcc.Input(id='gamma_r_3', type='number', value=19, step=0.01, className='input-field'),
html.Div(style={'display': 'flex', 'alignItems': 'center', 'whiteSpace': 'nowrap'}, children=[
html.Label([f'γ′',
html.Div(className='tooltip', children=[
html.Img(src='/assets/info-icon.png', className='info-icon', alt='Info'),
html.Span('Submerged unit weight of Sand-2', className='tooltiptext')
])], className='input-label', style={'marginRight': '5px'}),
html.Div(id='gamma_prime_3', className='input-field')
]),
]),
]),
# Graphs container
html.Div(className='graph-container', id='graphs-container', style={'display': 'flex', 'flexDirection': 'row', 'width': '75%'},
children=[
html.Div(style={'width': '20%', 'height': '100%'}, children=[
dcc.Graph(id='soil-layers-graph', style={'height': '100%', 'width': '100%'})
]),
html.Div(style={'width': '40%', 'height': '100%'}, children=[
dcc.Graph(id='pressure-graph', style={'height': '100%', 'width': '100%'})
]),
html.Div(style={'width': '40%', 'height': '100%'}, children=[
dcc.Graph(id='settelment-graph', style={'height': '100%', 'width': '100%'})
])
]),
# Add the logo image to the top left corner
html.Img(
src='/assets/logo.png', className='logo',
style={
'position': 'absolute',
'width': '15%', # Adjust size as needed
'height': 'auto',
'z-index': '1000', # Ensure it's on top of other elements
}
)
])
])
# Callback to control the bounderies of the input fields and sliders
@app.callback(
[Output(f'gamma_prime_{i}', 'children') for i in range(1, 4)],
Output('water-table', 'max'),
[Input(f'gamma_r_{i}', 'value') for i in range(1, 4)],
Input('z-1', 'value'),
)
def update_gamma_prime(gamma_r1, gamma_r2, gamma_r3, z1):
# Calculate γ′ as γ_r - 9.81 for each layer
gamma_prime1 = round(gamma_r1 - 10, 2) if gamma_r1 is not None else None
gamma_prime2 = round(gamma_r2 - 10, 2) if gamma_r2 is not None else None
gamma_prime3 = round(gamma_r3 - 10, 2) if gamma_r3 is not None else None
# water table max cannot be more than z1
water_table_max = z1
return f"= {gamma_prime1} kN/m³", f"= {gamma_prime2} kN/m³", f"= {gamma_prime3} kN/m³", water_table_max
# Callback to handle the animations and input updates
@app.callback(
[Output('soil-layers-graph', 'figure'),
Output('pressure-graph', 'figure'),
Output('settelment-graph', 'figure')],
[Input('update-button', 'n_clicks'),
State('time-slider', 'value')],
[State('z-1', 'value'),
State('z-2', 'value'),
State('z-3', 'value'),
State('delta_sigma', 'value'),
State('gamma_1', 'value'),
State('gamma_r_1', 'value'),
State('gamma_2', 'value'),
State('gamma_r_2', 'value'),
State('gamma_3', 'value'),
State('gamma_r_3', 'value'),
State('m_v', 'value'),
State('k', 'value'),
State('water-table', 'value')]
)
def update_graphs(n_clicks, t, z1, z2, z3, delta_sigma, gamma_1, gamma_r_1, gamma_2, gamma_r_2,
gamma_3, gamma_r_3, m_v, k, water_table):
# Constants
gamma_water = 10 # kN/m³ for water
# total depth
total_depth = z1 + z2 + z3
# Ensure y_top has a default value
y_top = -0.1*total_depth
# Define soil layers and their boundaries with specified patterns
layers = [
{'layer_id': '1', 'name': 'Sand-1', 'thickness' : z1,'top': 0, 'bottom': z1, 'color': 'rgb(244,164,96)','fillpattern': {'shape': '.'},
'x0': -0.2,'text':'h\u2081'
}, # Dots for Sand
{'layer_id': '2', 'name': 'Clay', 'thickness' : z2, 'top': z1, 'bottom': z1 + z2, 'color': 'rgb(139,69,19)',
'fillpattern': {'shape': ''}, 'x0': 0
}, # Dashes for Clay
{'layer_id': '3', 'name': 'Sand-2', 'thickness' : z3, 'top': z1 + z2, 'bottom': z1 + z2 + z3, 'color': 'rgb(244,164,96)',
'fillpattern': {'shape': '.'}, 'x0': -0.70, 'text':'h\u2083'
}, # Dots for Sand
]
# Create the soil layers figure (139,69,19)
soil_layers_fig = go.Figure()
pressure_fig = go.Figure()
settelment_fig = go.Figure()
for layer in layers:
if layer['thickness'] > 0:
soil_layers_fig.add_trace(go.Scatter(
x=[0, 0, 1, 1], # Create a rectangle-like shape
y=[layer['top'], layer['bottom'], layer['bottom'], layer['top']],
fill='toself',
fillcolor=layer['color'], # Transparent background to see the pattern
line=dict(width=1, color='black'),
name=layer['name'],
showlegend=False,
hoverinfo='skip', # Skip the hover info for these layers
fillpattern=layer['fillpattern'] # Use the specified fill pattern
))
# Add a line at the top and bottom of each layer
soil_layers_fig.add_trace(go.Scatter(
x=[0, 1], # Start at -1 and end at 1
y=[layer['top'], layer['top']], # Horizontal line at the top of the layer
mode='lines',
line=dict(color='black', width=1, dash='dash'),
showlegend=False, # Hide legend for these lines
hoverinfo='skip' # Skip the hover info for these line
))
# Add the annotation for the layer name
mid_depth = (layer['top'] + layer['bottom']) / 2 # Midpoint of the layer
soil_layers_fig.add_annotation(
x=0.4, # Position the text slightly to the right of the layer box
y=mid_depth,
text=layer['name'], # Layer name as text
font = dict(size=14, color="white", weight='bold'),
showarrow=False, # Don't show an arrow
xanchor='left', # Anchor text to the left
yanchor='middle' # Center text vertically with the midpoint
)
# Add a line at the water table
soil_layers_fig.add_trace(go.Scatter(
x=[0, 1], # Start at -1 and end at 1
y=[0, 0], # Horizontal line at the top of the layer
mode='lines',
line=dict(color='blue', width=2, dash='dot'),
showlegend=False, # Hide legend for these lines
hoverinfo='skip' # Skip the hover info for these line
))
# adding arrowas distributed load on the foundation
num_arrows = 10
for i in range(0, int(num_arrows+1)):
soil_layers_fig.add_annotation(
x=i*0.1, # x-coordinate of arrow head
y=0, # y-coordinate of arrow head
ax=i*0.1, # x-coordinate of tail
ay=0.9*y_top, # y-coordinate of tail
xref="x",
yref="y",
axref="x",
ayref="y",
showarrow=True,
arrowhead=2,
arrowsize=1,
arrowwidth=2,
arrowcolor="black"
)
soil_layers_fig.add_trace(go.Scatter(
x=[0, 1],
y=[0, 0], # Horizontal line at the top of the layer
mode='lines',
line=dict(color='black', width=4, dash='solid'),
showlegend=False, # Hide legend for these lines
hoverinfo='skip' # Skip the hover info for these line
))
# adding text for the load delta sigma
soil_layers_fig.add_annotation(
x=0.5, # Position the text slightly to the right of the layer box
y=y_top,
text='Δσ', # Layer name as text
font = dict(size=14, color="black", weight='bold'),
showarrow=False, # Don't show an arrow
xanchor='center', # Anchor text to the left
yanchor='middle' # Center text vertically with the midpoint
)
# add a line for the water table
soil_layers_fig.add_trace(go.Scatter(
x=[0, 1], # Start at -1 and end at 1
y=[water_table, water_table], # Horizontal line at the top of the layer
mode='lines',
line=dict(color='blue', width=2, dash='dot'),
showlegend=False, # Hide legend for these lines
hoverinfo='skip' # Skip the hover info for these line
))
# First figure (soil_layers_fig)
soil_layers_fig.update_layout(
plot_bgcolor='white',
xaxis_title= dict(text='Width (m)', font=dict(weight='bold')),
xaxis=dict(
range=[0, 1], # Adjusting the x-range as needed
showticklabels=False,
showgrid=False,
title=None,
zeroline=False
),
yaxis_title= dict(text='Depth (m)', font=dict(weight='bold')),
yaxis=dict(
range=[total_depth, y_top], # Adjusted range for the y-axis (inverted for depth)
showticklabels=True,
ticks='outside',
title_standoff=4,
ticklen=5,
minor_ticks="inside",
showline=True,
linewidth=2,
linecolor='black',
zeroline=False,
# scaleanchor="x", # Link y-axis scaling with x-axis
# scaleratio=1,
),
margin=dict(l=20, r=10),
)
# Calculate pore water pressure based on conditions
step = 0.05
z1_depth = np.linspace(0, z1, num=int(z1/step)+1)
z2_depth = np.linspace(z1, z1+z2, num=int(z2/step)+1)
z3_depth = np.linspace(z1+z2, z1+z2+z3, num=int(z3/step)+1)
depths = np.concatenate((z1_depth, z2_depth, z3_depth))
total_stress_z1 = np.zeros_like(z1_depth)
total_stress_z2 = np.zeros_like(z2_depth)
total_stress_z3 = np.zeros_like(z3_depth)
pore_pressure_z1 = np.zeros_like(z1_depth)
pore_pressure_z2 = np.zeros_like(z2_depth)
pore_pressure_z3 = np.zeros_like(z3_depth)
effective_stress_z1 = np.zeros_like(z1_depth)
effective_stress_z2 = np.zeros_like(z2_depth)
effective_stress_z3 = np.zeros_like(z3_depth)
settelment_z2 = np.zeros_like(z2_depth)
# condition for the first layer
for i, depth in enumerate(z1_depth):
if depth <= water_table:
total_stress_z1[i] = depth * gamma_1 + delta_sigma
pore_pressure_z1[i] = 0
else:
total_stress_z1[i] = total_stress_z1[int(water_table/step)] + (depth - water_table) * gamma_r_1
pore_pressure_z1[i] = (depth-water_table) * gamma_water
effective_stress_z1[i] = total_stress_z1[i] - pore_pressure_z1[i]
# condition for the second layer
for i, depth in enumerate(z2_depth):
total_stress_z2[i] = total_stress_z1[int(z1/step)] + (depth - z1) * gamma_r_2
# pore water pressure
if z3 == 0:
H = z2
else:
H = z2/2
c_v = k/(m_v * gamma_water)
t_99 = (1.4832*(H)**2)/c_v
T_v = ((t/100) * t_99* c_v)/(H)**2
if t == 100:
U = 1
elif T_v >= 0 and T_v < (1/12):
U = np.sqrt(4*T_v/3)
else:
U = 1 - (2/3)*np.exp((1/4)-(3*T_v))
# Calculate excess pore pressure using the series summation method
if t == 0:
excess_pore_pressure = delta_sigma
elif t == 100:
excess_pore_pressure = 0
else:
M = np.pi/2 * (2 * np.arange(0, 100) + 1) # Mode numbers
excess_pore_pressure = (2 * delta_sigma / M) * np.sin(M * (depth - z1) / (H)) * np.exp(-M**2 * T_v)
excess_pore_pressure = np.sum(excess_pore_pressure) # Sum up for all modes
pore_pressure_z2[i] = (depth - water_table) * gamma_water + excess_pore_pressure
effective_stress_z2[i] = total_stress_z2[i] - pore_pressure_z2[i]
settelment_z2[i] = 1000*(delta_sigma-excess_pore_pressure) * m_v * step
# condition for the third layer
for i, depth in enumerate(z3_depth):
total_stress_z3[i] = total_stress_z2[int(z2/step)] + (depth+-z1-z2) * gamma_r_3
pore_pressure_z3[i] = (depth-water_table) * gamma_water
effective_stress_z3[i] = total_stress_z3[i] - pore_pressure_z3[i]
# Combine the results for all layers
total_stress = np.concatenate((total_stress_z1, total_stress_z2, total_stress_z3))
pore_pressure = np.concatenate((pore_pressure_z1, pore_pressure_z2, pore_pressure_z3))
effective_stress = np.concatenate((effective_stress_z1, effective_stress_z2, effective_stress_z3))
# Create the pore pressure figure
for layer in layers:
# Add a line at the bottom of each layer other graph
pressure_fig.add_trace(go.Scatter(
x=[0, 1.2 * max(max(total_stress), max(pore_pressure), max(effective_stress))],
y=[layer['bottom'], layer['bottom']],
mode='lines',
line=dict(color='black', width=1, dash='dash'),
showlegend=False,
hoverinfo='skip'
))
pressure_fig.add_trace(go.Scatter(
x=total_stress,
y=depths,
mode='lines',
line=dict(color='red', width=3 ),
name='Total Vertical Stress, σ<sub>T</sub>'
))
pressure_fig.add_trace(go.Scatter(
x=pore_pressure,
y=depths,
mode='lines',
line=dict(color='blue', width=3 ),
name='Pore Water Pressure, u'
))
pressure_fig.add_trace(go.Scatter(
x=effective_stress,
y=depths,
mode='lines',
line=dict(color='green', width=3 ),
name='Effective Vertical Stress, σ\''
))
# draw the original pore water pressuer line
pressure_fig.add_trace(go.Scatter
(
x=[0, (total_depth - water_table) * gamma_water],
y=[water_table, total_depth],
mode='lines',
line=dict(color='blue', width=3, dash='dot'),
name='Initial Pore Water Pressure, u<sub>0</sub>'
))
pressure_fig.update_layout(
xaxis_title=dict(text='Stress/pressure (kPa)', font=dict(weight='bold')),
plot_bgcolor='white',
xaxis=dict(
range=[0, 1.2 * max(max(total_stress), max(pore_pressure), max(effective_stress))],
side='top',
title_standoff=4,
zeroline=False,
showticklabels=True,
ticks='outside',
ticklen=5,
minor_ticks="inside",
showline=True,
linewidth=2,
linecolor='black',
showgrid=False,
gridwidth=1,
gridcolor='lightgrey',
mirror=True,
hoverformat=".2f" # Sets hover value format for x-axis to two decimal places
),
yaxis_title=dict(text='Depth (m)', font=dict(weight='bold')),
yaxis=dict(
range=[total_depth, y_top],
zeroline=True,
zerolinecolor= "black",
title_standoff=4,
showticklabels=True,
ticks='outside',
ticklen=5,
minor_ticks="inside",
showline=True,
linewidth=2,
linecolor='black',
showgrid=False,
gridwidth=1,
gridcolor='lightgrey',
mirror=True,
hoverformat=".3f" # Sets hover value format for y-axis to two decimal places
),
legend=dict(
yanchor="top", # Align the bottom of the legend box
y=1, # Position the legend at the bottom inside the plot
xanchor="right", # Align the right edge of the legend box
x=1, # Position the legend at the right inside the plot
font= dict(size=10), # Adjust font size
bgcolor="rgba(255, 255, 255, 0.7)", # Optional: Semi-transparent white background
bordercolor="black", # Optional: Border color
borderwidth=1 # Optional: Border width
),
margin=dict(l=10, r=10),
)
accummultive_settelment = np.cumsum(np.sort(settelment_z2)[::-1])
# print(accummultive_settelment)
# Calculate the settlement for the second layer
for layer in layers:
# Add a line at the bottom of each layer other graph
settelment_fig.add_trace(go.Scatter(
x=[0, 1.2 * max(accummultive_settelment)], # Start at -1 and end at 1
y=[layer['bottom'], layer['bottom']], # Horizontal line at the top of the layer
mode='lines',
line=dict(color='black', width=1, dash='dash'),
showlegend=False, # Hide legend for these lines
hoverinfo='skip' # Skip the hover info for these line
))
settelment_fig.add_trace(go.Scatter(
x=accummultive_settelment,
y=np.sort(z2_depth)[::-1],
mode='lines',
line=dict(color='red', width=3 ),
name='Accumultive primary consolidation settelment, 𝜌'
))
# adding text to show U value at the middle of Clay layer
settelment_fig.add_annotation(
x=0.3*max(accummultive_settelment), # Position the text slightly to the right of the layer box
y=0.8*(z1 + z2/2),
text=f'U = {U*100:.0f}%', # Layer name as text
font = dict(size=14, color="red", weight='bold'),
showarrow=False, # Don't show an arrow
xanchor='center', # Anchor text to the left
bgcolor="yellow",
yanchor='middle' # Center text vertically with the midpoint
)
settelment_fig.update_layout(
xaxis_title=dict(text='Primary consolidation settelment (mm)', font=dict(weight='bold')),
plot_bgcolor='white',
xaxis=dict(
range=[0, 1.2 * max(accummultive_settelment)],
side='top',
title_standoff=4,
zeroline=False,
showticklabels=True,
ticks='outside',
ticklen=5,
minor_ticks="inside",
showline=True,
linewidth=2,
linecolor='black',
showgrid=False,
gridwidth=1,
gridcolor='lightgrey',
mirror=True,
hoverformat=".2f" # Sets hover value format for x-axis to two decimal places
),
yaxis_title=dict(text='Depth (m)', font=dict(weight='bold')),
yaxis=dict(
range=[total_depth, y_top],
zeroline=True,
zerolinecolor= "black",
title_standoff=4,
showticklabels=True,
ticks='outside',
ticklen=5,
minor_ticks="inside",
showline=True,
linewidth=2,
linecolor='black',
showgrid=False,
gridwidth=1,
gridcolor='lightgrey',
mirror=True,
hoverformat=".2f" # Sets hover value format for y-axis to two decimal places
),
legend=dict(
yanchor="top", # Align the bottom of the legend box
y=1, # Position the legend at the bottom inside the plot
xanchor="right", # Align the right edge of the legend box
x=1, # Position the legend at the right inside the plot
font= dict(size=10), # Adjust font size
bgcolor="rgba(255, 255, 255, 0.7)", # Optional: Semi-transparent white background
bordercolor="black", # Optional: Border color
borderwidth=1 # Optional: Border width
),
margin=dict(l=10, r=10),
)
return soil_layers_fig, pressure_fig, settelment_fig
# Run the Dash app
if __name__ == '__main__':
app.run_server(debug=True)
# Expose the server
server = app.server