2828 metavar = "MEMORY" ,
2929 help = "Weak scaling: memory per rank in GB. Strong scaling: global memory in GB. Used to determine cell count." ,
3030)
31- parser .add_argument (
32- "--rdma_mpi" ,
33- metavar = "RDMA" ,
34- type = str ,
35- choices = ["T" , "F" ],
36- default = "F" ,
37- help = "Enable RDMA-aware MPI optimizations." )
38- parser .add_argument (
39- "--n-steps" ,
40- metavar = "N" ,
41- type = int ,
42- default = 20 ,
43- help = "Number of time steps to simulate." )
44- parser .add_argument (
45- "--n-save" ,
46- metavar = "NS" ,
47- type = int ,
48- default = 20 ,
49- help = "Number of time steps between saves." )
31+ parser .add_argument ("--rdma_mpi" , metavar = "RDMA" , type = str , choices = ["T" , "F" ], default = "F" , help = "Enable RDMA-aware MPI optimizations." )
32+ parser .add_argument ("--n-steps" , metavar = "N" , type = int , default = 20 , help = "Number of time steps to simulate." )
33+ parser .add_argument ("--n-save" , metavar = "NS" , type = int , default = 20 , help = "Number of time steps between saves." )
5034args = parser .parse_args ()
5135
5236if args .scaling is None :
5943# Number of ranks.
6044nranks = args .mfc ["nodes" ] * args .mfc ["tasks_per_node" ]
6145
46+
6247# This subroutine finds three factors of n that are as close to each other as possible.
6348def closest_three_factors (n ):
6449 best_triplet = None
65- min_range = float (' inf' )
50+ min_range = float (" inf" )
6651
6752 # Iterate over possible first factor a
68- for a in range (1 , int (n ** (1 / 3 )) + 2 ): # a should be around the cube root of n
69- if n % a == 0 :
70- n1 = n // a # Remaining part
53+ for factor_one in range (1 , int (n ** (1 / 3 )) + 2 ): # factor_one should be around the cube root of n
54+ if n % factor_one == 0 :
55+ n1 = n // factor_one # Remaining part
7156
7257 # Iterate over possible second factor b
73- for b in range (a , int (math .sqrt (n1 )) + 2 ): # b should be around sqrt of n1
74- if n1 % b == 0 :
75- c = n1 // b # Third factor
58+ for factor_two in range (factor_one , int (math .sqrt (n1 )) + 2 ): # factor_two should be around sqrt of n1
59+ if n1 % factor_two == 0 :
60+ factor_three = n1 // factor_two # Third factor
7661
77- triplet_range = c - a # Spread of the numbers
62+ triplet_range = factor_three - factor_one # Spread of the numbers
7863 if triplet_range < min_range :
7964 min_range = triplet_range
80- best_triplet = (a , b , c )
65+ best_triplet = (factor_one , factor_two , factor_three )
8166
8267 return best_triplet
8368
69+
8470def nxyz_from_ncells_weak (ncells : float ) -> typing .Tuple [int , int , int ]:
8571 s = math .floor (ncells ** (1 / 3 ))
8672 ND = closest_three_factors (nranks )
@@ -89,17 +75,19 @@ def nxyz_from_ncells_weak(ncells: float) -> typing.Tuple[int, int, int]:
8975 N1 = ND [0 ] * s - 1
9076 N2 = ND [1 ] * s - 1
9177 N3 = ND [2 ] * s - 1
92- Lx = ND [0 ]
93- Ly = ND [1 ]
94- Lz = ND [2 ]
95- return N1 , N2 , N3 , Lx , Ly , Lz
78+ L1 = ND [0 ]
79+ L2 = ND [1 ]
80+ L3 = ND [2 ]
81+ return N1 , N2 , N3 , L1 , L2 , L3
82+
9683
9784def nxyz_from_ncells_strong (ncells : float ) -> typing .Tuple [int , int , int ]:
9885 s = round (ncells ** (1 / 3 ))
99- Lx = 4
100- Ly = 4
101- Lz = 4
102- return s , s , s , Lx , Ly , Lz
86+ L1 = 4
87+ L2 = 4
88+ L3 = 4
89+ return s , s , s , L1 , L2 , L3
90+
10391
10492if args .scaling == "weak" :
10593 Nx , Ny , Nz , Lx , Ly , Lz = nxyz_from_ncells_weak (cpg * args .memory )
@@ -117,32 +105,32 @@ def nxyz_from_ncells_strong(ncells: float) -> typing.Tuple[int, int, int]:
117105ISD = 5.0 / 8 * D0
118106
119107## pre-shock properties - AIR
120- p0a = patm # pressure - Pa
121- rho0a = 1.204 # density - kg/m3
122- gama = 1.40 # gamma
123- pia = 0 # pi infinity - Pa
124- c_a = math .sqrt (gama * (p0a + pia ) / rho0a ) # speed of sound - M/s
108+ p0a = patm # pressure - Pa
109+ rho0a = 1.204 # density - kg/m3
110+ gama = 1.40 # gamma
111+ pia = 0 # pi infinity - Pa
112+ c_a = math .sqrt (gama * (p0a + pia ) / rho0a ) # speed of sound - M/s
125113
126114## Droplet - WATER
127115rho0w = 1000 # density - kg/m3
128- p0w = patm # pressure - Pa
129- gamw = 6.12 # gamma
130- piw = 3.43e08 # pi infty - Pa
131- c_w = math .sqrt (gamw * (p0w + piw ) / rho0w ) # speed of sound - m/s
116+ p0w = patm # pressure - Pa
117+ gamw = 6.12 # gamma
118+ piw = 3.43e08 # pi infty - Pa
119+ c_w = math .sqrt (gamw * (p0w + piw ) / rho0w ) # speed of sound - m/s
132120
133121# Shock Mach number of interest
134122Min = 2.4
135123
136124# Pos to pre shock ratios - AIR
137- psOp0a = (Min ** 2 - 1 ) * 2 * gama / (gama + 1 ) + 1 # pressure
138- rhosOrho0a = (1 + (gama + 1 ) / (gama - 1 ) * psOp0a ) / ((gama + 1 ) / (gama - 1 ) + psOp0a ) # density
139- ss = Min * c_a # shock speed of sound - m/s
125+ psOp0a = (Min ** 2 - 1 ) * 2 * gama / (gama + 1 ) + 1 # pressure
126+ rhosOrho0a = (1 + (gama + 1 ) / (gama - 1 ) * psOp0a ) / ((gama + 1 ) / (gama - 1 ) + psOp0a ) # density
127+ ss = Min * c_a # shock speed of sound - m/s
140128
141129# post-shock conditions - AIR
142- ps = psOp0a * p0a # pressure - Pa
143- rhos = rhosOrho0a * rho0a # density - kg / m3
144- c_s = math .sqrt (gama * (ps + pia ) / rhos ) # post shock speed of sound - m/s
145- vel = c_a / gama * (psOp0a - 1.0 ) * p0a / (p0a + pia ) / Min # velocity at the post shock - m/s
130+ ps = psOp0a * p0a # pressure - Pa
131+ rhos = rhosOrho0a * rho0a # density - kg / m3
132+ c_s = math .sqrt (gama * (ps + pia ) / rhos ) # post shock speed of sound - m/s
133+ vel = c_a / gama * (psOp0a - 1.0 ) * p0a / (p0a + pia ) / Min # velocity at the post shock - m/s
146134
147135# Domain extents
148136xb = - Lx * D0 / 2
0 commit comments