From db2df9b0c43e35cfe0ac61e70db895414b911313 Mon Sep 17 00:00:00 2001 From: David Seus <david.seus@ians.uni-stuttgart.de> Date: Mon, 9 Dec 2019 15:23:23 +0100 Subject: [PATCH] setup other example --- ...istic-different-model-change_mesh_study.py | 163 +++++++++--------- 1 file changed, 82 insertions(+), 81 deletions(-) diff --git a/Two-phase-Two-phase/multi-patch/TP-TP-layered-soil-case-with-inner-patch/mesh_study/TP-TP-layered_soil_with_inner_patch-realistic-different-model-change_mesh_study.py b/Two-phase-Two-phase/multi-patch/TP-TP-layered-soil-case-with-inner-patch/mesh_study/TP-TP-layered_soil_with_inner_patch-realistic-different-model-change_mesh_study.py index 79a1d35..ad2ac36 100755 --- a/Two-phase-Two-phase/multi-patch/TP-TP-layered-soil-case-with-inner-patch/mesh_study/TP-TP-layered_soil_with_inner_patch-realistic-different-model-change_mesh_study.py +++ b/Two-phase-Two-phase/multi-patch/TP-TP-layered-soil-case-with-inner-patch/mesh_study/TP-TP-layered_soil_with_inner_patch-realistic-different-model-change_mesh_study.py @@ -30,28 +30,28 @@ sym.init_printing() use_case = "TP-TP-layered-soil-realistic-model-change-at-interface12" max_iter_num = 300 FEM_Lagrange_degree = 1 -mesh_study = False +mesh_study = True resolutions = { 1: 5e-4, # h=2 2: 5e-4, # h=1.1180 4: 3e-4, # h=0.5590 8: 1e-6, # h=0.2814 - 16: 1e-6, # h=0.1412 - 32: 1e-6, # h=0.0706 - 64: 1e-6, # 0.03535 - 128: 1e-6, # 0.01768 + 16: 9e-7, # h=0.1412 + 32: 9e-7, # h=0.0706 + 64: 9e-7, # 0.03535 + 128: 9e-7, # 0.01768 # 256: 1e-6 # 0.00884 } ############ GRID ####################### # mesh_resolution = 20 -timestep_size = 0.0005 -number_of_timesteps = 1100 +timestep_size = 0.001 +number_of_timesteps = 11 plot_timestep_every = 5 # decide how many timesteps you want analysed. Analysed means, that we write out # subsequent errors of the L-iteration within the timestep. number_of_timesteps_to_analyse = 6 -starttime = 0.0 +starttimes = [0.0] Lw = 0.025 #/timestep_size Lnw=Lw @@ -60,7 +60,7 @@ lambda_w = 20 lambda_nw = 20 include_gravity = False -debugflag = False +debugflag = True analyse_condition = True if mesh_study: @@ -75,11 +75,11 @@ if mesh_study: write_to_file = { 'space_errornorms': True, 'meshes_and_markers': True, - 'L_iterations_per_timestep': False, - 'solutions': False, - 'absolute_differences': False, + 'L_iterations_per_timestep': True, + 'solutions': True, + 'absolute_differences': True, 'condition_numbers': analyse_condition, - 'subsequent_errors': False + 'subsequent_errors': True } else: write_to_file = { @@ -752,71 +752,72 @@ for subdomain in isRichards.keys(): ) -for mesh_resolution, solver_tol in resolutions.items(): - # initialise LDD simulation class - simulation = ldd.LDDsimulation( - tol=1E-14, - LDDsolver_tol=solver_tol, - debug=debugflag, - max_iter_num=max_iter_num, - FEM_Lagrange_degree=FEM_Lagrange_degree, - mesh_study=mesh_study - ) - - simulation.set_parameters(use_case=use_case, - output_dir=output_string, - subdomain_def_points=subdomain_def_points, - isRichards=isRichards, - interface_def_points=interface_def_points, - outer_boundary_def_points=outer_boundary_def_points, - adjacent_subdomains=adjacent_subdomains, - mesh_resolution=mesh_resolution, - viscosity=viscosity, - porosity=porosity, - L=L, - lambda_param=lambda_param, - relative_permeability=relative_permeability, - saturation=sat_pressure_relationship, - starttime=starttime, - number_of_timesteps=number_of_timesteps, - number_of_timesteps_to_analyse=number_of_timesteps_to_analyse, - plot_timestep_every=plot_timestep_every, - timestep_size=timestep_size, - sources=source_expression, - initial_conditions=initial_condition, - dirichletBC_expression_strings=dirichletBC, - exact_solution=exact_solution, - densities=densities, - include_gravity=include_gravity, - write2file=write_to_file, - ) - - simulation.initialise() - output_dir = simulation.output_dir - # simulation.write_exact_solution_to_xdmf() - output = simulation.run(analyse_condition=analyse_condition) - for subdomain_index, subdomain_output in output.items(): - mesh_h = subdomain_output['mesh_size'] - for phase, different_errornorms in subdomain_output['errornorm'].items(): - filename = output_dir + "subdomain{}-space-time-errornorm-{}-phase.csv".format(subdomain_index, phase) - # for errortype, errornorm in different_errornorms.items(): - - # eocfile = open("eoc_filename", "a") - # eocfile.write( str(mesh_h) + " " + str(errornorm) + "\n" ) - # eocfile.close() - # if subdomain.isRichards:mesh_h - data_dict = { - 'mesh_parameter': mesh_resolution, - 'mesh_h': mesh_h, - } - for error_type, errornorms in different_errornorms.items(): - data_dict.update( - {error_type: errornorms} - ) - errors = pd.DataFrame(data_dict, index=[mesh_resolution]) - # check if file exists - if os.path.isfile(filename) == True: - with open(filename, 'a') as f: - errors.to_csv(f, header=False, sep='\t', encoding='utf-8', index=False) - else: - errors.to_csv(filename, sep='\t', encoding='utf-8', index=False) +for starttime in starttimes: + for mesh_resolution, solver_tol in resolutions.items(): + # initialise LDD simulation class + simulation = ldd.LDDsimulation( + tol=1E-14, + LDDsolver_tol=solver_tol, + debug=debugflag, + max_iter_num=max_iter_num, + FEM_Lagrange_degree=FEM_Lagrange_degree, + mesh_study=mesh_study + ) + + simulation.set_parameters(use_case=use_case, + output_dir=output_string, + subdomain_def_points=subdomain_def_points, + isRichards=isRichards, + interface_def_points=interface_def_points, + outer_boundary_def_points=outer_boundary_def_points, + adjacent_subdomains=adjacent_subdomains, + mesh_resolution=mesh_resolution, + viscosity=viscosity, + porosity=porosity, + L=L, + lambda_param=lambda_param, + relative_permeability=relative_permeability, + saturation=sat_pressure_relationship, + starttime=starttime, + number_of_timesteps=number_of_timesteps, + number_of_timesteps_to_analyse=number_of_timesteps_to_analyse, + plot_timestep_every=plot_timestep_every, + timestep_size=timestep_size, + sources=source_expression, + initial_conditions=initial_condition, + dirichletBC_expression_strings=dirichletBC, + exact_solution=exact_solution, + densities=densities, + include_gravity=include_gravity, + write2file=write_to_file, + ) + + simulation.initialise() + output_dir = simulation.output_dir + # simulation.write_exact_solution_to_xdmf() + output = simulation.run(analyse_condition=analyse_condition) + for subdomain_index, subdomain_output in output.items(): + mesh_h = subdomain_output['mesh_size'] + for phase, different_errornorms in subdomain_output['errornorm'].items(): + filename = output_dir + "subdomain{}-space-time-errornorm-{}-phase.csv".format(subdomain_index, phase) + # for errortype, errornorm in different_errornorms.items(): + + # eocfile = open("eoc_filename", "a") + # eocfile.write( str(mesh_h) + " " + str(errornorm) + "\n" ) + # eocfile.close() + # if subdomain.isRichards:mesh_h + data_dict = { + 'mesh_parameter': mesh_resolution, + 'mesh_h': mesh_h, + } + for error_type, errornorms in different_errornorms.items(): + data_dict.update( + {error_type: errornorms} + ) + errors = pd.DataFrame(data_dict, index=[mesh_resolution]) + # check if file exists + if os.path.isfile(filename) == True: + with open(filename, 'a') as f: + errors.to_csv(f, header=False, sep='\t', encoding='utf-8', index=False) + else: + errors.to_csv(filename, sep='\t', encoding='utf-8', index=False) -- GitLab