-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_single.py
54 lines (48 loc) · 2.27 KB
/
run_single.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
import numpy as np
from parallel_slab import (
GeneralizedMooneyRivlinSolution,
NeoHookeanSolution,
run_and_plot_from_yaml,
)
if __name__ == "__main__":
###############################################
## 1. Load from YAML
###############################################
sol = run_and_plot_from_yaml(
NeoHookeanSolution, # the type of solid material
final_time=20.0, # final time of simulation, till periodic steady state
plot_times=np.linspace(
12.0, 14.0, 20, endpoint=False
), # time at which you want to plot the solutions
param_file_name="params.yaml", # name of the parameters YAML file
rel_file_path="data", # folder to store simulation artefacts
write_flag=False, # write data files (as csv) and images (as pdf) at plot_times
animate_flag=False, # animate a movie sampled at plot_time and dump it as mp4
)
"""
###############################################
## 2. Load from YAML, default parameters
###############################################
# Many of the parameters are defaulted to the values shown above
# so that you only need to bother with the first two parameters
run_and_plot_from_yaml(
GeneralizedMooneyRivlinSolution, final_time=2.0 # the type of solid material
) # final time of simulation, till periodic steady state
###############################################
## 3. Output Grid
###############################################
# Finally we can control the details of the output grid
# using the grid_generator keyword parameter which accepts a
# callable object with two parameters (length of solid and fluid zones from YAML file)
# and outputs a tuple of solid and fluid grids
# This is for easily obtaining the solution at your simulation grid points
from parallel_slab.driver import generate_regular_grid
from functools import partial
# generate_regular_grid generates two grids with total n_total_points
grid_generator = partial(generate_regular_grid, 128)
run_and_plot_from_yaml(
NeoHookeanSolution, # the type of solid material
final_time=20.0, # final time of simulation, till periodic steady state
grid_generator=grid_generator,
)
"""