Skip to content

Commit

Permalink
Merge pull request #88 from joergbuchwald/ogs6py_ng
Browse files Browse the repository at this point in the history
make timesteps in output optional
  • Loading branch information
joergbuchwald authored Jul 4, 2024
2 parents fc95659 + 72559c4 commit 5bb9ac7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
36 changes: 18 additions & 18 deletions examples/example_THM.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# if MKL set vars vars script should be executed before OGS
# model = OGS(PROJECT_FILE="thm_test.prj", MKL=True, OMP_NUM_THREADS=4)
model = OGS(PROJECT_FILE="thm_test.prj", OMP_NUM_THREADS=4)
model.geo.add_geom(filename="square_1x1_thm.gml")
model.geometry.add_geometry(filename="square_1x1_thm.gml")
model.mesh.add_mesh(filename="quarter_002_2nd.vtu", axially_symmetric="true")
model.processes.set_process(
name="THERMO_HYDRO_MECHANICS",
Expand Down Expand Up @@ -115,27 +115,27 @@
model.media.add_property(medium_id="0",
name="thermal_conductivity",
type="EffectiveThermalConductivityPorosityMixing")
model.timeloop.add_process(process="THERMO_HYDRO_MECHANICS",
model.time_loop.add_process(process="THERMO_HYDRO_MECHANICS",
nonlinear_solver_name="basic_newton",
convergence_type="PerComponentDeltaX",
norm_type="NORM2",
abstols="1e-5 1e-5 1e-5 1e-5",
time_discretization="BackwardEuler")
model.timeloop.set_stepping(process="THERMO_HYDRO_MECHANICS",
model.time_loop.set_stepping(process="THERMO_HYDRO_MECHANICS",
type="FixedTimeStepping",
t_initial="0",
t_end="50000",
repeat="10",
delta_t="5000")
model.timeloop.add_output(
model.time_loop.add_output(
type="VTK",
prefix="blubb",
repeat="1",
each_steps="10",
variables=["displacement", "pressure", "temperature", "sigma", "epsilon"],
fixed_output_times=[1,2,3])
model.timeloop.add_time_stepping_pair(process="THERMO_HYDRO_MECHANICS", repeat="15", delta_t="32")
model.timeloop.add_output_pair(repeat="12", each_steps="11")
model.time_loop.add_time_stepping_pair(process="THERMO_HYDRO_MECHANICS", repeat="15", delta_t="32")
model.time_loop.add_output_pair(repeat="12", each_steps="11")
model.parameters.add_parameter(name="E", type="Constant", value="5000000000")
model.parameters.add_parameter(name="nu", type="Constant", value="0.3")
model.parameters.add_parameter(name="T0", type="Constant", value="273.15")
Expand All @@ -159,65 +159,65 @@
value="150")
model.curves.add_curve(name="time_curve", coords=[0.0, 1e6, 1.1e6, 5e6],
values=[1.0, 1.0, 2.0, 2.0])
model.processvars.set_ic(process_variable_name="displacement",
model.process_variables.set_ic(process_variable_name="displacement",
components="2",
order="2",
initial_condition="displacement0")
model.processvars.add_bc(process_variable_name="displacement",
model.process_variables.add_bc(process_variable_name="displacement",
geometrical_set="square_1x1_geometry",
geometry="left",
type="Dirichlet",
component="0",
parameter="dirichlet0")
model.processvars.add_bc(process_variable_name="displacement",
model.process_variables.add_bc(process_variable_name="displacement",
geometrical_set="square_1x1_geometry",
geometry="bottom",
type="Dirichlet",
component="1",
parameter="dirichlet0")
model.processvars.set_ic(process_variable_name="pressure",
model.process_variables.set_ic(process_variable_name="pressure",
components="1",
order="1",
initial_condition="pressure_ic")
model.processvars.add_bc(process_variable_name="pressure",
model.process_variables.add_bc(process_variable_name="pressure",
geometrical_set="square_1x1_geometry",
geometry="out",
type="Dirichlet",
component="0",
parameter="pressure_bc_left")
model.processvars.set_ic(process_variable_name="temperature",
model.process_variables.set_ic(process_variable_name="temperature",
components="1",
order="1",
initial_condition="temperature_ic")
model.processvars.add_bc(process_variable_name="temperature",
model.process_variables.add_bc(process_variable_name="temperature",
geometrical_set="square_1x1_geometry",
geometry="out",
type="Dirichlet",
component="0",
parameter="temperature_bc_left")
model.processvars.add_st(process_variable_name="temperature",
model.process_variables.add_st(process_variable_name="temperature",
geometrical_set="square_1x1_geometry",
geometry="center",
type="Nodal",
parameter="temperature_source_term")
model.nonlinsolvers.add_non_lin_solver(name="basic_newton",
model.nonlinear_solvers.add_non_lin_solver(name="basic_newton",
type="Newton",
max_iter="50",
linear_solver="general_linear_solver")
model.linsolvers.add_lin_solver(name="general_linear_solver",
model.linear_solvers.add_lin_solver(name="general_linear_solver",
kind="lis",
solver_type="bicgstab",
precon_type="ilu",
max_iteration_step="10000",
error_tolerance="1e-16")
model.linsolvers.add_lin_solver(name="general_linear_solver",
model.linear_solvers.add_lin_solver(name="general_linear_solver",
kind="eigen",
solver_type="SparseLU",
precon_type="DIAGONAL",
max_iteration_step="10000",
error_tolerance="1e-8",
scaling="1")
model.linsolvers.add_lin_solver(name="general_linear_solver",
model.linear_solvers.add_lin_solver(name="general_linear_solver",
kind="petsc",
prefix="sd",
solver_type="cg",
Expand Down
16 changes: 12 additions & 4 deletions examples/thm_test.prj
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version='1.0' encoding='ISO-8859-1'?>
<OpenGeoSysProject>
<geometry>square_1x1_thm.gml</geometry>
<mesh axially_symmetric="true">quarter_002_2nd.vtu</mesh>
<processes>
<process>
<name>THERMO_HYDRO_MECHANICS</name>
<type>THERMO_HYDRO_MECHANICS</type>
<integration_order>4</integration_order>
<dimension>2</dimension>
<reference_temperature>T0</reference_temperature>
<specific_body_force>0 0</specific_body_force>
<constitutive_relation>
<type>LinearElasticIsotropic</type>
Expand Down Expand Up @@ -49,7 +47,12 @@
<independent_variable>
<variable_name>temperature</variable_name>
<reference_condition>273.15</reference_condition>
<slope>-4e-4</slope>
<slope>-0.0004</slope>
</independent_variable>
<independent_variable>
<variable_name>phase_pressure</variable_name>
<reference_condition>100000.0</reference_condition>
<slope>1e-20</slope>
</independent_variable>
</property>
<property>
Expand Down Expand Up @@ -111,6 +114,10 @@
<type>Constant</type>
<value>1.0</value>
</property>
<property>
<name>thermal_conductivity</name>
<type>EffectiveThermalConductivityPorosityMixing</type>
</property>
</properties>
</medium>
</media>
Expand Down Expand Up @@ -305,7 +312,7 @@
<name>general_linear_solver</name>
<lis>-i bicgstab -p ilu -tol 1e-16 -maxiter 10000</lis>
<eigen>
<solver_type>PardisoLU</solver_type>
<solver_type>SparseLU</solver_type>
<precon_type>DIAGONAL</precon_type>
<max_iteration_step>10000</max_iteration_step>
<error_tolerance>1e-8</error_tolerance>
Expand All @@ -317,4 +324,5 @@
</petsc>
</linear_solver>
</linear_solvers>
<geometry>square_1x1_thm.gml</geometry>
</OpenGeoSysProject>
4 changes: 2 additions & 2 deletions ogs6py/classes/timeloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ def add_output(self, **args):
for mesh in args["meshes"]:
self.populate_tree(meshes, 'mesh', text=mesh)
# material_id attribute missing
timesteps = self.populate_tree(self.output, 'timesteps')
if "repeat" in args:
timesteps = self.populate_tree(self.output, 'timesteps')
if "each_steps" not in args:
raise KeyError("each_steps is a required tag if repeat is given.")
if isinstance(args["repeat"], list) and isinstance(args["each_steps"], list):
Expand Down Expand Up @@ -286,7 +286,7 @@ def add_output_pair(self, **args):
each_steps : `int` or `str` or `list`
"""
self._convertargs(args)
timesteps = self.output.find("./timesteps")
timesteps = self.populate_tree(self.output, 'timesteps', overwrite=True)
if "repeat" in args and "each_steps" in args:
if isinstance(args["repeat"], list) and isinstance(args["each_steps"], list):
for i, entry in enumerate(args["repeat"]):
Expand Down

0 comments on commit 5bb9ac7

Please sign in to comment.