Skip to content

Commit f5d064f

Browse files
committed
rename hydrograph to timeDependentRelease; move the csv table and polygon to REL folder
1 parent 3a5357e commit f5d064f

File tree

10 files changed

+134
-201
lines changed

10 files changed

+134
-201
lines changed

avaframe/com1DFA/com1DFA.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,8 @@ def prepareReleaseEntrainment(cfg, rel, inputSimLines):
479479

480480
# set release thickness
481481

482-
if cfg["GENERAL"].getboolean("hydrograph") and cfg["GENERAL"].getboolean("noRelArea"):
483-
inputSimLines["hydrographAreaLine"]["thicknessSource"] = ["csv file"]
484-
log.info("Release scenario with hydrograph and without REL area.")
482+
if cfg["GENERAL"].getboolean("timeDependentRelease"):
483+
inputSimLines["releaseLine"]["thicknessSource"] = ["csv file"]
485484
elif cfg["INPUT"]["relThFile"] == "":
486485
releaseLine = setThickness(cfg, inputSimLines["releaseLine"], "relTh")
487486
inputSimLines["releaseLine"] = releaseLine
@@ -538,14 +537,14 @@ def setThickness(cfg, lineTh, typeTh):
538537
lineTh["thicknessSource"] = ["ini file"] * len(lineTh["thickness"])
539538
else:
540539
lineTh["thicknessSource"] = ["shp file"] * len(lineTh["thickness"])
541-
elif cfg["GENERAL"].getboolean("hydrograph") and cfg["GENERAL"].getboolean("noRelArea"):
540+
elif cfg["GENERAL"].getboolean("timeDependentRelease"):
542541
lineTh["thicknessSource"] = ["csv file"] * len(lineTh["thickness"])
543542
else:
544543
lineTh["thicknessSource"] = ["ini file"] * len(lineTh["thickness"])
545544

546545
# set thickness value info read from ini file that has been updated from shp or ini previously
547546
for count, id in enumerate(lineTh["id"]):
548-
if cfg["GENERAL"].getboolean("hydrograph") and cfg["GENERAL"].getboolean("noRelArea"):
547+
if cfg["GENERAL"].getboolean("timeDependentRelease"):
549548
lineTh["thickness"][count] = float(lineTh["thickness"][count])
550549

551550
elif cfg["GENERAL"].getboolean(thFlag):
@@ -572,8 +571,7 @@ def prepareInputData(inputSimFiles, cfg):
572571
- secondaryRelFile : str, path to secondaryRelease file
573572
- entFiles : str, path to entrainment file
574573
- resFile : str, path to resistance file
575-
- hydrographFile: str, path to hydrograph polygon file
576-
- hydrographCsv: str, path to hydrograph values (csv-)file
574+
- timeDepRelCsv: str, path to time dependent release values (csv-)file
577575
- entResInfo : flag dict
578576
flag if Yes entrainment and/or resistance areas found and used for simulation
579577
flag True if a Secondary Release file found and activated
@@ -597,7 +595,6 @@ def prepareInputData(inputSimFiles, cfg):
597595
- resLine : dict, resistance line dictionary
598596
- entrainmentArea : str, entrainment file name
599597
- resistanceArea : str, resistance file name
600-
- hydrographAreaLine: dict, hydrograph line dictionary
601598
- entResInfo : flag dict
602599
flag if Yes entrainment and/or resistance areas found and used for simulation
603600
flag True if a Secondary Release file found and activated
@@ -641,15 +638,14 @@ def prepareInputData(inputSimFiles, cfg):
641638
releaseLine["thickness"] = "from raster"
642639
log.info("Set %s for relThField" % relRasterPath)
643640
# get line from release area polygon
644-
if cfg["GENERAL"].getboolean("hydrograph") and cfg["GENERAL"].getboolean("noRelArea"):
645-
releaseLine["type"] = "Hydrograph"
646-
hydrValues = gI.getHydrographCsv(inputSimFiles["hydrographCsv"])
647-
releaseLine["thickness"] = [hydrValues["thickness"][hydrValues["timeStep"] == 0]]
641+
642+
if cfg["GENERAL"].getboolean("timeDependentRelease"):
643+
releaseLine["type"] = "time dependent Release"
644+
timeDepRelValues = gI.getTimeDepRelCsv(inputSimFiles["timeDepRelCsv"])
645+
releaseLine["thickness"] = [timeDepRelValues["thickness"][timeDepRelValues["timeStep"] == 0]]
648646
releaseLine["thicknessSource"] = ["csv file"]
649-
releaseLine["velocity"] = hydrValues["velocity"][hydrValues["timeStep"] == 0]
650-
gI.checkForMultiplePartsShpArea(
651-
cfg["GENERAL"]["avalancheDir"], releaseLine, "com1DFA", type="release"
652-
)
647+
releaseLine["velocity"] = timeDepRelValues["velocity"][timeDepRelValues["timeStep"] == 0]
648+
releaseLine["timeDepRelValues"] = timeDepRelValues
653649

654650
# get line from secondary release area polygon
655651
if cfg["GENERAL"].getboolean("secRelArea"):
@@ -764,10 +760,8 @@ def prepareInputData(inputSimFiles, cfg):
764760
else:
765761
damLine = None
766762

767-
if cfg["GENERAL"].getboolean("hydrograph"):
768-
hydrLine = debF.preparehydrographAreaLine(inputSimFiles, demOri, cfg)
769-
else:
770-
hydrLine = None
763+
if cfg["GENERAL"].getboolean("timeDependentRelease"):
764+
releaseLine = debF.prepareTimeDepRelLine(inputSimFiles, releaseLine, cfg)
771765

772766
inputSimLines = {
773767
"releaseLine": releaseLine,
@@ -784,7 +778,6 @@ def prepareInputData(inputSimFiles, cfg):
784778
"xiFile": inputSimFiles["xiFile"],
785779
"kFile": inputSimFiles["kFile"],
786780
"tauCFile": inputSimFiles["tauCFile"],
787-
"hydrographAreaLine": hydrLine,
788781
}
789782

790783
return demOri, inputSimLines
@@ -1233,7 +1226,7 @@ def initializeSimulation(cfg, outDir, demOri, inputSimLines, logName):
12331226
logName=logName,
12341227
relThField=relThField,
12351228
)
1236-
if cfgGen.getboolean("hydrograph") and cfgGen.getboolean("noRelArea"):
1229+
if cfgGen.getboolean("timeDependentRelease"):
12371230
particles = DFAfunC.updateInitialVelocity(cfgGen, particles, dem, releaseLine["velocity"])
12381231
particles, fields = initializeFields(cfg, dem, particles, releaseLine)
12391232

@@ -1643,7 +1636,7 @@ def getRelThFromPart(cfg, releaseLine, relThField, thName):
16431636

16441637
if len(relThField) != 0:
16451638
relThForPart = np.amax(relThField)
1646-
elif releaseLine["type"] == "Hydrograph":
1639+
elif cfg.getboolean("timeDependentRelease"):
16471640
relThForPart = releaseLine["thickness"]
16481641
elif cfg.getboolean("%sThFromFile" % thName):
16491642
relThForPart = np.amax(np.asarray(releaseLine["thickness"], dtype=float))
@@ -2164,8 +2157,8 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si
21642157
startTime = time.time()
21652158
log.debug("Computing time step t = %f s, dt = %f s" % (t, dt))
21662159

2167-
if cfgGen.getboolean("hydrograph"):
2168-
particles, fields, zPartArray0 = debF.releaseHydrograph(
2160+
if cfgGen.getboolean("timeDependentRelease"):
2161+
particles, fields, zPartArray0 = debF.initializeTimeDepRelease(
21692162
cfg, inputSimLines, particles, fields, dem, zPartArray0, t
21702163
)
21712164
# Perform computations
@@ -3493,8 +3486,8 @@ def fetchRelVolume(releaseFile, cfg, pathToDem, secondaryReleaseFile, radius=0.0
34933486
demVol = geoTrans.getNormalMesh(demVol, num=methodMeshNormal)
34943487
demVol = DFAtls.getAreaMesh(demVol, methodMeshNormal)
34953488

3496-
if cfg["GENERAL"].getboolean("hydrograph") and cfg["GENERAL"].getboolean("noRelArea"):
3497-
relVolume = initializeRelVol(cfg, demVol, releaseFile, radius, releaseType="hydrograph")
3489+
if cfg["GENERAL"].getboolean("timeDependentRelease"):
3490+
relVolume = initializeRelVol(cfg, demVol, releaseFile, radius, releaseType="timeDepRel")
34983491
else:
34993492
# compute volume of release area
35003493
relVolume = initializeRelVol(cfg, demVol, releaseFile, radius, releaseType="primary")
@@ -3542,10 +3535,8 @@ def initializeRelVol(cfg, demVol, releaseFile, radius, releaseType="primary"):
35423535
35433536
"""
35443537

3545-
if releaseType == "primary":
3538+
if releaseType in ["primary", "timeDepRel"]:
35463539
typeTh = "relTh"
3547-
elif releaseType == "hydrograph":
3548-
typeTh = "hydrTh"
35493540
else:
35503541
typeTh = "secondaryRelTh"
35513542

avaframe/com1DFA/com1DFACfg.ini

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,21 @@ entThDistVariation =
132132
# entrainment thickness (only considered if ENT file is shapefile and entThFromFile=False) [m]
133133
entTh =
134134

135-
#+++++++++++++Hydrograph
136-
# if hydrograph is True, add hydrograph, provide the hydrograph values in a csv-table in the HYDR folder
137-
hydrograph = False
138-
# when checking if an already existing particle is within a hydrograph polygon
135+
#+++++++++++++general start conditions: time dependent release
136+
# if timeDependentRelease is True, provide the the timesteps, thickness and velocity
137+
# for a releases in a csv-table in the REL folder
138+
timeDependentRelease = False
139+
# when checking if an already existing particle is within a release polygon
139140
# (that would cause numerical instabilities and rise an error), one can decide to add a buffer
140141
# around the polygon (0 means take strictly the points inside, a very small value
141142
# will include the points located on the polygon line)
142-
thresholdPointInHydr = 0.01
143+
thresholdPointInRel = 0.01
143144
# disabled at the moment:
144-
# distance that particles need to travel before new particles are initialized through the hydrograph
145-
# the distance is computed out of the hydrograph timesteps and the hydrograph velocity,
145+
# distance that particles need to travel before new particles are initialized through the a general release
146+
# the distance is computed out of the general release timesteps and velocity,
146147
# if the velocity is 0, it's set to 1 m/s:
147148
# (distance = (timestep[i] - timestep[i-1]) * velocity)
148149
timeStepDistance = 5
149-
# if hydrograph is True and noRelArea is True, REL area is not used.
150-
# In the hydrograph (csv-table) a thickness value at time step 0 needs to be provided.
151-
noRelArea = True
152150

153151
#++++++++++++Time stepping parameters
154152
# fixed time step (also used as first time step when using CFL) [s]

0 commit comments

Comments
 (0)