Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psimpy
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
mbd
psimpy
Commits
256aad8f
Commit
256aad8f
authored
1 year ago
by
Nicholas Book
Browse files
Options
Downloads
Patches
Plain Diff
Fixed phase separation and entrainment control
parent
64f0d9a1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/psimpy/simulator/__init__.py
+2
-1
2 additions, 1 deletion
src/psimpy/simulator/__init__.py
src/psimpy/simulator/ravaflow3G.py
+28
-32
28 additions, 32 deletions
src/psimpy/simulator/ravaflow3G.py
with
30 additions
and
33 deletions
src/psimpy/simulator/__init__.py
+
2
−
1
View file @
256aad8f
from
psimpy.simulator.mass_point_model
import
MassPointModel
from
psimpy.simulator.ravaflow24
import
Ravaflow24Mixture
from
psimpy.simulator.ravaflow3G
import
Ravaflow3GMixture
from
psimpy.simulator.run_simulator
import
RunSimulator
This diff is collapsed.
Click to expand it.
src/psimpy/simulator/ravaflow3G.py
+
28
−
32
View file @
256aad8f
...
...
@@ -19,12 +19,11 @@ class Ravaflow3GMixture:
curvature_control
:
str
=
"
1
"
,
surface_control
:
str
=
"
0
"
,
entrainment_control
:
str
=
"
0
"
,
shear_velocity_coef
:
float
=
0.05
,
basal_friction_diff
:
float
=
0.0
,
stopping_control
:
str
=
"
0
"
,
stopping_threshold
:
float
=
0.0
,
friction_control
:
str
=
"
0
"
,
non_hydro_control
:
str
=
"
0
"
,
phase_sep_control
:
str
=
"
0
"
,
hydrograph_control
:
str
=
"
2
"
,
deceleration_control
:
str
=
"
0
"
,
)
->
None
:
...
...
@@ -56,29 +55,22 @@ class Ravaflow3GMixture:
`
'
1
'
`: apply balancing of forces.
entrainment_control : str
`
'
0
'
`: no entrainment (default).
`
'
1
'
`: the entrainment coefficient is multiplied with flow momentum.
`
'
1
'
`: the entrainment coefficient
(see `preprocess`)
is multiplied with flow momentum.
`
'
2
'
`: simplified entrainment and deposition model is used.
`
'
3
'
`: combination of `
'
1
'
` for entrainmnet and `
'
2
'
` for deposition.
`
'
4
'
`: acceleration-deceleration entrainment and deposition model.
shear_velocity_coef : float
Only used with ``entrainment_control`` being `
'
2
'
` or `
'
3
'
`, range
:math:`[0,1]`.
basal_friction_diff : float
Difference between the basal friction angles of the basal surface
and the flow, in degrees. Only used with ``entrainment_control``
being `
'
2
'
` or `
'
3
'
`.
stopping_control : str
`
'
0
'
`: no stopping control is used (default).
`
'
1
'
`: stop if the flow kinetic energy is equal or smaller than
a
given threshold.
`
'
2
'
`: stop if the flow momentum is equal or smaller than
a given
threshold.
`
'
1
'
`: stop if the flow kinetic energy
ratio
is equal or smaller than
given threshold
``stopping_threshold``
.
`
'
2
'
`: stop if the flow momentum
ratio
is equal or smaller than
given
threshold
``stopping_threshold``
.
`
'
3
'
`: stop if the dynamic flow pressure of all raster cells is
euqal or smaller than a given threshold.
stopping_threshold : float
Threshold value for
`
`stopping_control`
`
.
If
`
`stopping_control`
`
is `
'
1
'
` or `
'
2
'
`, ``stopping_threshold``
has to be given
as the maximum value reached during the flow
.
Threshold value for `stopping_control`.
If `stopping_control` is `
'
1
'
` or `
'
2
'
`,
a
``stopping_threshold``
has to be given
with respect to maximal flow kinetic energy/momentum
.
If ``stopping_control`` is `
'
3
'
`, the pressure threshold has to be
specified.
friction_control : str, optional
...
...
@@ -90,6 +82,9 @@ class Ravaflow3GMixture:
`
'
1
'
`: Only dispersion is considered.
`
'
2
'
`: Only enhanced gravity is considered.
`
'
3
'
`: Both dispersion and enhanced gravity are considered.
phase_sep_control: str
`
'
0
'
`: Phase separation is neglected (default).
`
'
1
'
`: Phase separation is considered.
hydrograph_control: str
`
'
0
'
`: Impose hydrograph on the flow.
`
'
1
'
`: Reset flow at the hydrograph profile before imposing the hydrograph.
...
...
@@ -124,9 +119,6 @@ class Ravaflow3GMixture:
raise
ValueError
(
"
entrainment_control must be
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
, or
'
4
'"
)
self
.
entrainment_control
=
entrainment_control
self
.
shear_velocity_coef
=
shear_velocity_coef
self
.
basal_friction_diff
=
basal_friction_diff
if
stopping_control
not
in
[
"
0
"
,
"
1
"
,
"
2
"
,
"
3
"
]:
raise
ValueError
(
"
stopping_control must be
'
0
'
,
'
1
'
,
'
2
'
, or
'
3
'"
)
self
.
stopping_control
=
stopping_control
...
...
@@ -141,6 +133,10 @@ class Ravaflow3GMixture:
raise
ValueError
(
"
non_hydro_control must be
'
0
'
,
'
1
'
,
'
2
'
, or
'
3
'"
)
self
.
non_hydro_control
=
non_hydro_control
if
phase_sep_control
not
in
[
"
0
"
,
"
1
"
]:
raise
ValueError
(
"
phase_sep_control must be
'
0
'
or
'
1
'
.
"
)
self
.
phase_sep_control
=
phase_sep_control
if
hydrograph_control
not
in
[
"
0
"
,
"
1
"
,
"
2
"
]:
raise
ValueError
(
"
hydrograph_control must be
'
0
'
,
'
1
'
, or
'
2
'"
)
self
.
hydrograph_control
=
hydrograph_control
...
...
@@ -164,7 +160,7 @@ class Ravaflow3GMixture:
EPSG
:
Union
[
str
,
None
]
=
None
,
)
->
tuple
[
str
,
str
]:
"""
Preprocess simulation input data
simulation
.
Preprocess simulation input data.
Parameters
----------
...
...
@@ -195,9 +191,9 @@ class Ravaflow3GMixture:
except for :math:`0` meaning no entrainment.
EPSG : str, optional
`EPSG` (European Petroleum Survey Group) code to create
`
GRASS Location <https://grass.osgeo.org/grass82/manuals/grass_database.html>
`_
.
GRASS Location <https://grass.osgeo.org/grass82/manuals/grass_database.html>.
If `None`, ``elevation`` must be a georeferenced file which has
metadata to create the
`
GRASS Location
`
.
metadata to create the GRASS Location.
Returns
-------
...
...
@@ -205,7 +201,7 @@ class Ravaflow3GMixture:
Name of the `GRASS Location` (including path).
sh_file : str
Name of the shell file (including path), which will be called by
`GRASS <https://grass.osgeo.org/>`
_
to run the simulation.
`GRASS <https://grass.osgeo.org/>` to run the simulation.
"""
sh_file
=
os
.
path
.
join
(
self
.
dir_sim
,
f
"
{
prefix
}
_shell.sh
"
)
...
...
@@ -230,18 +226,19 @@ class Ravaflow3GMixture:
# create grass location
if
EPSG
is
None
:
os
.
system
(
f
"
grass -
e -c
{
elevation
}
{
grass_location
}
"
)
os
.
system
(
f
"
grass -
c XY -e
{
grass_location
}
"
)
else
:
os
.
system
(
f
"
grass -e -c EPSG:
{
EPSG
}
{
grass_location
}
"
)
# create shell file
with
open
(
sh_file
,
"
w
"
)
as
sh
:
sh
.
write
(
"
# import elevation raster
\n
"
)
sh
.
write
(
"
g.region -d
\n
"
)
sh
.
write
(
f
"
r.in.gdal -o input=
{
elevation
}
output=elev --overwrite
"
)
sh
.
write
(
"
\n\n
"
)
sh
.
write
(
"
# set region based on elev
\n
"
)
sh
.
write
(
"
g.region raster=elev
\n\n
"
)
sh
.
write
(
"
g.region
-s
raster=elev
\n\n
"
)
sh
.
write
(
"
# import hrelease raster
\n
"
)
sh
.
write
(
f
"
r.in.gdal -o input=
{
hrelease
}
output=raw_hrel --overwrite
"
)
...
...
@@ -255,12 +252,11 @@ class Ravaflow3GMixture:
f
"
elevation=elev hrelease=hrel
"
f
"
friction=
{
internal_friction
}
,
{
basal_friction
}
,
"
f
"
{
turbulent_friction
}
"
f
"
basal=
{
entrainment_coef
}
,
{
self
.
shear_velocity_coef
}
,
"
f
"
{
self
.
basal_friction_diff
}
,
{
self
.
stopping_threshold
}
"
f
"
basal=
{
entrainment_coef
}
,
{
self
.
stopping_threshold
}
"
f
"
controls=0,
{
self
.
diffusion_control
}
,
{
self
.
curvature_control
}
,
"
f
"
{
self
.
surface_control
}
,
{
self
.
entrainment_control
}
,
"
f
"
{
self
.
stopping_control
}
,
{
self
.
friction_control
}
,
{
self
.
non_hydro_control
}
,
"
f
"
{
self
.
hydrograph_control
}
,
{
self
.
deceleration_control
}
"
f
"
{
self
.
phase_sep_control
}
,
{
self
.
hydrograph_control
}
,
{
self
.
deceleration_control
}
"
f
"
time=
{
self
.
time_step
}
,
{
self
.
time_end
}
"
f
"
cfl=
{
self
.
cfl
}
,
{
self
.
time_step_length
}
"
)
...
...
@@ -311,7 +307,7 @@ class Ravaflow3GMixture:
`
'
t
'
`: maximum flow kinetic energy, in :math:`J`.
threshold : float or int
Threshold of ``qoi`` to determine impact area. Areas where ``qoi``
is larger than ``threshold`` are regarded as impa
r
area.
is larger than ``threshold`` are regarded as impa
ct
area.
Returns
-------
...
...
@@ -356,9 +352,9 @@ class Ravaflow3GMixture:
`
'
p
'
`: maximum flow pressure, in :math:`Pa`.
`
'
t
'
`: maximum flow kinetic energy, in :math:`J`.
aggregate : bool
If `True`, returns the overall maximum value over all spatio-tempo
If `True`, returns the overall maximum value over all spatio-tempo
ral
grids. If `False`, returns the maximum values over all time steps at
each spati
o
location, namely a raster of maximum values.
each spati
al
location, namely a raster of maximum values.
Returns
-------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment