tgenerate-rate-state-scripts-comet-rs1.py - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
tgenerate-rate-state-scripts-comet-rs1.py (4490B)
---
1 #!/usr/bin/env python
2
3 # rs1: relative to rs0 set top wall mass to equal total particle mass, disable
4 # wall viscosity
5
6 # Account and cluster information
7 # https://portal.xsede.org/sdsc-comet
8 # https://www.sdsc.edu/support/user_guides/comet.html
9 account = 'csd492' # from `show_accounts`
10 jobname_prefix = 'rs1-'
11 walltime = '2-0' # hours:minutes:seconds or days-hours
12 partition = 'gpu-shared'
13 no_gpus = 1
14 no_nodes = 1
15 ntasks_per_node = 1
16 folder = '~/code/sphere/python'
17
18
19 # Simulation parameter values
20 effective_stresses = [10e3, 20e3, 100e3, 200e3, 1000e3, 2000e3]
21 velfacs = [0.1, 1.0, 10.0]
22 mu_s_vals = [0.5]
23 mu_d_vals = [0.5]
24
25
26 # Script generating functions
27
28 def generate_slurm_script(jobname):
29
30 script = '''#!/bin/bash
31 #SBATCH -A {account}
32 #SBATCH --job-name="{jobname}"
33 #SBATCH --output="{jobname}.%j.%N.out"
34 #SBATCH --time={walltime}
35 #SBATCH --partition={partition}
36 #SBATCH --gres=gpu:{no_gpus}
37 #SBATCH --nodes={no_nodes}
38 #SBATCH --ntasks-per-node={ntasks_per_node}
39 #SBATCH --export=ALL
40
41 echo Job start `whoami`@`hostname`, `date`
42 module load cmake
43 module load cuda/7.0
44 module load python
45 module load scipy
46
47 cd {folder}
48 python ./{jobname}.py
49
50 echo Job end `whoami`@`hostname`, `date`
51 '''.format(account=account,
52 jobname=jobname,
53 walltime=walltime,
54 partition=partition,
55 no_gpus=no_gpus,
56 no_nodes=no_nodes,
57 ntasks_per_node=ntasks_per_node,
58 folder=folder)
59 with open(jobname + '.sh', 'w') as file:
60 file.write(script)
61
62
63 def generate_slurm_continue_script(jobname):
64
65 script = '''#!/bin/bash
66 #SBATCH -A {account}
67 #SBATCH --job-name="{jobname}"
68 #SBATCH --output="{jobname}.%j.%N.out"
69 #SBATCH --time={walltime}
70 #SBATCH --partition={partition}
71 #SBATCH --gres=gpu:{no_gpus}
72 #SBATCH --nodes={no_nodes}
73 #SBATCH --ntasks-per-node={ntasks_per_node}
74 #SBATCH --export=ALL
75
76 echo Job start `whoami`@`hostname`, `date`
77 module load cmake
78 module load cuda/7.0
79 module load python
80 module load scipy
81
82 cd {folder}
83 python ./continue_sim.py {jobname} 0
84
85 echo Job end `whoami`@`hostname`, `date`
86 '''.format(account=account,
87 jobname=jobname,
88 walltime=walltime,
89 partition=partition,
90 no_gpus=no_gpus,
91 no_nodes=no_nodes,
92 ntasks_per_node=ntasks_per_node,
93 folder=folder)
94 with open(jobname + '-cont.sh', 'w') as file:
95 file.write(script)
96
97
98 # Generate scripts for sphere
99 def generate_simulation_script(jobname, effective_stress, velfac, mu_s, mu_d):
100
101 script = '''#!/usr/bin/env python
102 import sphere
103 import numpy
104
105 # load consolidated granular assemblage
106 sim = sphere.sim(fluid=False)
107 cons_jobname = 'cons-1e4-' + '{{}}Pa'.format({effective_stress})
108 sim = sphere.sim(cons_jobname, fluid=False)
109 sim.readlast()
110 sim.id('{jobname}')
111
112 sim.checkerboardColors(nx=6, ny=6, nz=6)
113 sim.cleanup()
114 sim.adjustUpperWall()
115 sim.zeroKinematics()
116
117 sim.shear(1.0/20.0 * {velfac})
118
119 sim.setStiffnessNormal(1.16e7)
120 sim.setStiffnessTangential(1.16e7)
121 sim.setStaticFriction({mu_s})
122 sim.setDynamicFriction({mu_d})
123 sim.setDampingNormal(0.0)
124 sim.setDampingTangential(0.0)
125
126 sim.w_sigma0[0] = {effective_stress}
127 sim.w_m[0] = sim.totalMass()
128 sim.gamma_wn[0] = 0.0
129
130 sim.initTemporal(total = 20.0, file_dt = 0.01, epsilon=0.07)
131
132 I = numpy.nonzero(sim.fixvel > 0)
133 sim.fixvel[I] = 8.0 # step-wise velocity change when fixvel in ]5.0; 10.0[
134
135 sim.run(dry=True)
136 sim.run(device=0)
137 sim.writeVTKall()
138 sim.visualize('shear')
139 '''.format(jobname=jobname,
140 effective_stress=effective_stress,
141 velfac=velfac,
142 mu_s=mu_s,
143 mu_d=mu_d)
144
145 with open(jobname + '.py', 'w') as file:
146 file.write(script)
147
148
149 # Generate scripts
150 for effective_stress in effective_stresses:
151 for velfac in velfacs:
152 for mu_s in mu_s_vals:
153 for mu_d in mu_s_vals:
154
155 jobname = jobname_prefix + '{}Pa-v={}-mu_s={}-mu_d={}'.format(
156 effective_stress,
157 velfac,
158 mu_s,
159 mu_d)
160
161 print(jobname)
162
163 # Generate scripts for slurm, submit with `sbatch <script>`
164 generate_slurm_script(jobname)
165
166 generate_slurm_continue_script(jobname)
167
168 generate_simulation_script(jobname,
169 effective_stress,
170 velfac,
171 mu_s,
172 mu_d)