Python API and Merged Single Phase and Two Phases Code
Pre-release
Pre-release
See INSTALL file in root TITAN2D directory for installation details, now you also need Python and SWIG in order to compile TITAN2D.
The titan now is executed as (TITAN_HOME should point to TITAN2D root installation directory):
#load environment
source $(TITAN_HOME)/bin/titanvars.sh
#parallel execution
mpirun -np 4 $(TITAN_HOME)/bin/titan simulation_script.py
Here is example of simulation script for single phase:
sim=TitanSinglePhase(
length_scale=4000.0,
gravity_scale=9.8,
height_scale=None,
max_iter=1000,
max_time=2400.0,
time_save=2400.0,
adapt=True,
order='First',
short_speed=True,
vizoutput="XDMF/Paraview",
time_output=120,
edge_height=None,
test_height=None,
test_location=None
)
sim.setGIS(
gis_format='GIS_GRASS',
gis_main='/home/mikola/titan_wsp/',
gis_sub='dems',
gis_mapset='colimafine',
gis_map='colima',
gis_vector=None,
min_location_x=None,
min_location_y=None,
max_location_x=None,
max_location_y=None,
)
sim.setMatMap(
number_of_cells_across_axis=48,
use_gis_matmap=False,
int_frict=37.0,
bed_frict=27.0
)
sim.addPile(
height=30.0,
center=[644956.0, 2157970.0],
radii=[55.0, 55.0],
orientation=0.0,
Vmagnitude=0.0,
Vdirection=0.0
)
sim.addFluxSource(
influx=10.0,
start_time=0.0,
end_time=10000.0,
center=[644956.0, 2157970.0],
radii=[55.0, 55.0],
orientation=0.0,
Vmagnitude=0.0,
Vdirection=0.0
)
sim.addDischargePlane(637380.0, 2145800.0, 664380.0, 2169800.0)
sim.run()
Note that in this script all possible variables are set for illustration what can be set, many of them has default values and don't really need to be specified.
Here is example of two phases simulations
sim=TitanTwoPhases(
length_scale=4000.0,
gravity_scale=9.8,
height_scale=30.0,
max_iter=200,
max_time=2400.0,
time_save=10.0,
adapt=True,
order='First',
short_speed=False,
time_output=1,
vizoutput="XDMF/Paraview",
edge_height=None,
test_height=None,
test_location=None
)
sim.setGIS(
gis_format='GIS_GRASS',
gis_main='/home/mikola/titan_wsp/',
gis_sub='dems',
gis_mapset='colimafine',
gis_map='colima',
gis_vector=None,
min_location_x=None,
min_location_y=None,
max_location_x=None,
max_location_y=None,
)
sim.setMatMap(
number_of_cells_across_axis=48,
use_gis_matmap=False,
int_frict=37.0,
bed_frict=27.0
)
sim.addPile(
height=30.0,
center=[644956.0, 2157970.0],
radii=[55.0, 55.0],
orientation=0.0,
Vmagnitude=0.0,
Vdirection=0.0,
vol_fract=0.7,
pile_type='PARABALOID'
)
sim.run()
Note that single phase and two phases has different short_speed and pile_type settings.
This release have passed binary identity test to v3.0.1 for both short_speed and pile_type settings in case if both versions are compiled without any optimizations, i.e. -g -O0