def resolution_study(): run_shell_command("make") N = 256 num_stencil = [ int(i*N) for i in [ 1/2, 1, 2, ]] dt = 0.0005 re = 80 steps = 10_000 initial_steps = 25_000 resolution_folder = "resolution_study_3" for n in num_stencil: for skip_diffusion in [0,1]: diff_str = skip_diffusion_to_str(skip_diffusion) folder_name = f"{n}" case = RunCase( skip_diffusion=skip_diffusion, size = n, dt = dt, steps = steps, restarts = 0, reynolds_number=re, path = f"{BASE_SAVE}/{resolution_folder}/{diff_str}/{folder_name}", load_initial_data=2, export_vtk=True, skip_steps=initial_steps ) wrap_error_case(case, f"{BASE_SAVE}/{resolution_folder}/errors.txt")
def temporal_study(): run_shell_command("make") DT = 0.0005 STEPS = 10_000 INITIAL_STEPS = 25_000 timesteps = [ [i*DT, int(STEPS / i), int(INITIAL_STEPS / i)] for i in [ 1/2, 1, 2, ]] N = 256 re = 80 temporal_folder = "temporal_study_3" print("timesteps are", timesteps) for dt, steps, initial_steps in timesteps: for skip_diffusion in [0,1]: diff_str = skip_diffusion_to_str(skip_diffusion) folder_name = f"{dt}" case = RunCase( skip_diffusion=skip_diffusion, size = N, dt = dt, steps = steps, restarts = 0, reynolds_number=re, path = f"{BASE_SAVE}/{temporal_folder}/{diff_str}/{folder_name}", load_initial_data=2, export_vtk=True, skip_steps=initial_steps ) wrap_error_case(case, f"{BASE_SAVE}/{temporal_folder}/errors.txt")
def forcing_cases(): delta_1 = 0.1 delta_2 = 0.1 run_shell_command("make") batch_name = f"forcing_viscous_7" save_json_folder = f"{BASE_SAVE}/{batch_name}" if not os.path.exists(save_json_folder): os.mkdir(save_json_folder) for f in os.listdir(save_json_folder): os.remove(os.path.join(save_json_folder, f)) END_TIME = 5 dt = 0.0005 size = 128 re = 40 steps = int(END_TIME / dt) save_vtk = True extra_caps = [] io_steps = 38 copy_init_files(size) epsilon_generator = EpsilonControl.load_json() cases = [ [0.0, 0.0, "baseline"], [-1 * delta_1, 0.0, "ep1-neg"], [0.0, -1 * delta_2, "ep2-neg"], ] output_folder = define_output_folder() for skip_diffusion in [0, 1]: # TODO: remove this after generating if skip_diffusion == 1: continue for delta_1, delta_2, folder in cases: diffusion_str = skip_diffusion_to_str(skip_diffusion) epsilon1 = epsilon_generator.epsilon_1(delta_1) epsilon2 = epsilon_generator.epsilon_2(delta_2) case = RunCase( skip_diffusion=skip_diffusion, size=size, dt=dt, steps=steps, restarts=0, restart_time=1.0, reynolds_number=re, path=output_folder, load_initial_data=0, epsilon1=epsilon1, epsilon2=epsilon2, export_vtk=save_vtk, # scalar_type=14, scalar_type=0, io_steps=io_steps, ) case.write_to_json(f"{folder}_{diffusion_str}", save_json_folder) copy_distribute_files(save_json_folder, batch_name, extra_caps) build = Build("master", "master") build.to_json(save_json_folder)
def full_system_test(): delta_1 = 0.1 delta_2 = 0.1 n = 20 run_shell_command("make") batch_name = f"system_test_{n}" save_json_folder = f"{BASE_SAVE}/{batch_name}" if not os.path.exists(save_json_folder): os.mkdir(save_json_folder) for _ in os.listdir(save_json_folder): raise ValueError("folder should be empty") dt = 0.0005 size = 128 re = 40 steps = 500 save_vtk = True extra_caps = [] io_steps = 10 copy_init_files(size) epsilon_generator = EpsilonControl.load_json() cases = [ # [0., 0., "baseline"], [-1 * delta_1, 0.0, "ep1-neg"], [0.0, -1 * delta_2, "ep2-neg"], ] output_folder = define_output_folder() for delta_1, delta_2, folder in cases: diffusion_str = skip_diffusion_to_str(0) epsilon1 = epsilon_generator.epsilon_1(delta_1) epsilon2 = epsilon_generator.epsilon_2(delta_2) case = RunCase( skip_diffusion=0, size=size, dt=dt, steps=steps, restarts=0, reynolds_number=re, path=output_folder, load_initial_data=0, epsilon1=epsilon1, epsilon2=epsilon2, export_vtk=save_vtk, scalar_type=14, # scalar_type=0, io_steps=io_steps, ) case.write_to_json(f"{folder}_{diffusion_str}", save_json_folder) copy_distribute_files(save_json_folder, batch_name, extra_caps) build = Build("master", "master") build.to_json(save_json_folder)
def forcing_sweep(): # Conclusion: # for viscous cases, the max I values are # ep1 : 1 -> 10^(i-2) -> 0.1 # ep2 : 3 -> 10^(i-2) -> 10 run_shell_command("make") n = 5 forcing_folder = f"epsilon_parameter_sweep_{n}" save_json_folder = f"{BASE_SAVE}/{forcing_folder}" if not os.path.exists(save_json_folder): os.mkdir(save_json_folder) for _ in os.listdir(save_json_folder): raise ValueError("directory is not empty") # os.remove(os.path.join(save_json_folder, f)) END_TIME = 10 dt = 0.0005 size = 128 re = 40 steps = int(END_TIME / dt) save_vtk = False batch_name = forcing_folder extra_caps = [] copy_init_files(size) epsilon_generator = EpsilonControl.load_json() cases = [] NUM_CASES = 10 delta_1_max = 0.5 delta_1_min = 0.01 delta_1_inc = (delta_1_max - delta_1_min) / (NUM_CASES - 1) delta_2_max = 100 delta_2_min = 0.1 delta_2_inc = (delta_2_max - delta_2_min) / (NUM_CASES - 1) for epsilon_value in [1, 2]: for i in range(0, NUM_CASES): if epsilon_value == 1: delta = delta_1_min + (delta_1_inc * i) newcase = [delta, 0, f"ep1-{i}"] else: delta = delta_2_min + (delta_2_inc * i) newcase = [0, delta, f"ep2-{i}"] cases.append(newcase) delta_1_cases = [i for i, _, _ in cases[0:NUM_CASES]] epsilon_1_cases = [epsilon_generator.epsilon_1(i) for i in delta_1_cases] z1 = list(zip(delta_1_cases, epsilon_1_cases)) delta_2_cases = [i for _, i, _ in cases[NUM_CASES:]] epsilon_2_cases = [epsilon_generator.epsilon_2(i) for i in delta_2_cases] z2 = list(zip(delta_2_cases, epsilon_2_cases)) print("asdf") print(f"forced energy cases:") pprint(z1) print(f"forced helicity cases:") pprint(z2) if IS_SINGULARITY and IS_DISTRIBUTED: output_folder = f"/distribute_save/" else: output_folder = f"../../distribute_save/" for skip_diffusion in [0, 1]: # TODO: remove this after generating if skip_diffusion == 1: continue for delta_1, delta_2, folder in cases: diffusion_str = skip_diffusion_to_str(skip_diffusion) epsilon1 = epsilon_generator.epsilon_1(delta_1) epsilon2 = epsilon_generator.epsilon_2(delta_2) if epsilon1 == -0.0: epsilon1 = 0.0 if epsilon2 == -0.0: epsilon2 = 0.0 print("ep1: {:.5E} ep2: {:.5E}".format(epsilon1, epsilon2)) case = RunCase( skip_diffusion=skip_diffusion, size=size, dt=dt, steps=steps, restarts=0, restart_time=1.0, reynolds_number=re, path=output_folder, load_initial_data=0, epsilon1=epsilon1, epsilon2=epsilon2, export_vtk=save_vtk, scalar_type=14, ) case.write_to_json(f"{folder}_{diffusion_str}", save_json_folder) copy_distribute_files(save_json_folder, batch_name, extra_caps) build = Build("master", "master") build.to_json(save_json_folder)