def prepare_input(config_file): # get simulation inputs from configuration file lambd, mu, rho, min_x, max_x, min_y, max_y, min_z, max_z, N_x, N_y, N_z, t_0, t_f, N_t, outfile = parse_input(config_file) # Grid spacing in each dimension # We divide by N_i - 1 so that we include L_x in our boundary dx = (max_x - min_x) / N_x dy = (max_y - min_y) / N_y dz = (max_z - min_z) / N_z # Timestep dt = (t_f - t_0) / N_t # Grid size in each direction L_x = np.float64(max_x) - np.float64(min_x) L_y = np.float64(max_y) - np.float64(min_y) L_z = np.float64(max_z) - np.float64(min_z) return N_x, N_y, N_z, N_t, L_x, L_y, L_z, dx, dy, dz, dt, mu, rho, lambd, t_0, t_f, outfile if __name__ == '__main__': import sys config_file = sys.argv[1] # Run the simulation! go(*(prepare_input(config_file)))
lambd, mu, rho, min_x, max_x, min_y, max_y, min_z, max_z, N_x, N_y, N_z, t_0, t_f, N_t, outfile = parse_input(config_file) # Grid spacing in each dimension # We divide by N_i - 1 so that we include L_x in our boundary dx = (max_x - min_x) / N_x dy = (max_y - min_y) / N_y dz = (max_z - min_z) / N_z # Timestep dt = (t_f - t_0) / N_t # Grid size in each direction L_x = np.float64(max_x) - np.float64(min_x) L_y = np.float64(max_y) - np.float64(min_y) L_z = np.float64(max_z) - np.float64(min_z) return N_x, N_y, N_z, N_t, L_x, L_y, L_z, dx, dy, dz, dt, mu, rho, lambd, t_0, t_f, outfile if __name__ == '__main__': import sys config_file = sys.argv[1] opts = prepare_input(config_file) outfile = opts[-1] with Timer() as t: go(*opts) with open('time-{}'.format(outfile), 'w') as file: print(t.interval, file=file)
config_file) # Grid spacing in each dimension # We divide by N_i - 1 so that we include L_x in our boundary dx = (max_x - min_x) / N_x dy = (max_y - min_y) / N_y dz = (max_z - min_z) / N_z # Timestep dt = (t_f - t_0) / N_t # Grid size in each direction L_x = np.float64(max_x) - np.float64(min_x) L_y = np.float64(max_y) - np.float64(min_y) L_z = np.float64(max_z) - np.float64(min_z) return N_x, N_y, N_z, N_t, L_x, L_y, L_z, dx, dy, dz, dt, mu, rho, lambd, t_0, t_f, outfile if __name__ == '__main__': import sys config_file = sys.argv[1] opts = prepare_input(config_file) outfile = opts[-1] with Timer() as t: go(*opts) with open('time-{}'.format(outfile), 'w') as file: print(t.interval, file=file)
N_x = 100 N_y = 100 N_z = 100 # Grid spacing in each dimension dx = (max_x - min_x) / N_x dy = (max_y - min_y) / N_y dz = (max_z - min_z) / N_z # Total simulation time and number of time points t_0 = 0 t_f = 1 N_t = 100 ts = np.linspace(t_0, t_f, N_t) dt = (t_f - t_0) / N_t # Number of parameters stored at each grid point num_params = 20 # Instantiate the grid # +2 for ghost regions at the edge # grid = np.zeros( (N_x + 2, N_y + 2, N_z + 2, num_params), dtype=np.float64_t ) # Run the simulation with nogil: go(N_x, N_y, N_z, N_t, np.float64(dx), np.float64(dy), np.float64(dz), np.float64(dt), np.float64(mu), np.float64(rho), np.float64(lambd), np.float64(t_0), np.float64(t_f), ts) # grid)