Repository navigation
[com1DFA] Add TJEM entrainment model #1339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8d5de30
d57746d
1bcf0af
54664a2
2873a91
1e9ab76
7077a5d
167255c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ import avaframe.in3Utils.geoTrans as geoTrans | |
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def computeForceC(cfg, particles, fields, dem, int frictType, int resistanceType): | ||
| def computeForceC(cfg, particles, fields, dem, int frictType, int entrType, int resistanceType): | ||
| """ compute forces acting on the particles (without the SPH component) | ||
|
|
||
| Cython implementation implementation | ||
|
|
@@ -44,6 +44,8 @@ def computeForceC(cfg, particles, fields, dem, int frictType, int resistanceType | |
| dictionary with dem information | ||
| frictType: int | ||
| identifier for friction law to be used | ||
| entrType: int | ||
| identifier for entrainment law to be used | ||
| resistanceType: int | ||
| identifier for resistance model to be used | ||
|
|
||
|
|
@@ -73,6 +75,7 @@ def computeForceC(cfg, particles, fields, dem, int frictType, int resistanceType | |
| cdef double BSamosAtMedium = cfg.getfloat('Bsamosatmedium') | ||
| cdef double RSamosAtMedium = cfg.getfloat('Rsamosatmedium') | ||
| cdef double entEroEnergy = cfg.getfloat('entEroEnergy') | ||
| cdef double entShearStrength = cfg.getfloat('entShearStrength') | ||
| cdef double entShearResistance = cfg.getfloat('entShearResistance') | ||
| cdef double entDefResistance = cfg.getfloat('entDefResistance') | ||
| cdef double rho = cfg.getfloat('rho') | ||
|
|
@@ -393,7 +396,10 @@ def computeForceC(cfg, particles, fields, dem, int frictType, int resistanceType | |
| entrMassCell = entrMassRaster[indCellY, indCellX] | ||
| if entrMassCell > 0.0: | ||
| # compute entrained mass | ||
| dm, areaEntrPart = computeEntMassAndForce(dt, entrMassCell, areaPart, uMag, tau, entEroEnergy, rhoEnt) | ||
| if entrType == 1: | ||
| dm, areaEntrPart = computeEntMassAndForce(dt, entrMassCell, areaPart, uMag, tau, entEroEnergy, rhoEnt) | ||
| if entrType == 2: | ||
| dm, areaEntrPart, tau = computeEntMassAndForceTjem(dt, entrMassCell, areaPart, uMag, tau, entShearStrength, rhoEnt) | ||
| # speed loss due to energy loss due to entrained mass | ||
| dEnergyEntr = areaEntrPart * entShearResistance + dm * entDefResistance | ||
|
|
||
|
|
@@ -542,6 +548,54 @@ cpdef (double, double) computeEntMassAndForce(double dt, double entrMassCell, | |
|
|
||
| return dm, areaEntrPart | ||
|
|
||
| cpdef (double, double, double) computeEntMassAndForceTjem(double dt, double entrMassCell, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rhoEnt is passed, but never used |
||
| double areaPart, double uMag, | ||
| double tau, double entShearStrength, | ||
| double rhoEnt): | ||
| """ compute force component due to entrained mass | ||
|
|
||
| Parameters | ||
| ---------- | ||
| dt: float | ||
| time step | ||
| entrMassCell : float | ||
| available mass for entrainement | ||
| areaPart : float | ||
| particle area | ||
| uMag : float | ||
| particle speed (velocity magnitude) | ||
| tau : float | ||
| bottom shear stress | ||
|
|
||
| Returns | ||
| ------- | ||
| dm : float | ||
| entrained mass | ||
| areaEntrPart : float | ||
| Area for entrainment energy loss computation | ||
| entShearStrength: float | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these 2 parameters should not be under returns, but under parameters |
||
| shear strength of the entrainable snow mass | ||
| rhoEnt: float | ||
| entrainement density | ||
| """ | ||
| cdef double width, ABotSwiped | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are unused, remove |
||
| # compute entrained mass | ||
| cdef double dm = 0.0 | ||
| cdef double areaEntrPart = 0.0 | ||
|
|
||
| if entrMassCell > 0: | ||
|
|
||
| # erosion: erode according to shear strength of snow cover | ||
| # in contrast to MoTVoellmy tau_c here is not scaled with the flow density | ||
| # because com1DFA does not scale shear stress at the bottom of the avalanche with the flow density while MoTVoellmy does | ||
| tau_c = entShearStrength | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use camelCase (tauC) |
||
| dm = max(0, tau - tau_c) * areaPart * dt / uMag | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for resting particles uMag is 0 -> so you get a divide by 0! So protect with velMagMin (similar to friction code) and also cap dm by teh pass available in the cell
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use max (0.0, ...) -> with double instead of int |
||
| areaEntrPart = areaPart | ||
| if dm > 0: | ||
| tau = min(tau, tau_c) | ||
|
|
||
| return dm, areaEntrPart, tau | ||
|
|
||
|
|
||
| cpdef double computeDetMass(double dt, double detCell, | ||
| double areaPart, double uMag): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2189,6 +2189,17 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si | |
| frictType = frictModelsList.index(frictModel) + 1 | ||
| log.debug("Friction Model used: %s, %s" % (frictModelsList[frictType - 1], frictType)) | ||
|
|
||
| # derive entrainment type | ||
| # turn entrainment model into integer | ||
| entrModelsList = [ | ||
| "avaframe", | ||
| "tjem", | ||
| ] | ||
| entrModel = cfgGen["entrModel"].lower() | ||
| entrType = entrModelsList.index(entrModel) + 1 | ||
| log.debug("Entrainment Model used: %s, %s" % (entrModelsList[entrType - 1], entrType)) | ||
| print("Entrainment Model used: %s, %s" % (entrModelsList[entrType - 1], entrType)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove print |
||
|
|
||
| # turn resistance model into integer | ||
| ResModel = cfgGen["ResistanceModel"].lower() | ||
| ResModelsList = [ | ||
|
|
@@ -2301,6 +2312,7 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si | |
| dem, | ||
| tCPU, | ||
| frictType, | ||
| entrType, | ||
| resistanceType, | ||
| inputSimLines["reportAreaInfo"], | ||
| ) | ||
|
|
@@ -2723,6 +2735,7 @@ def computeEulerTimeStep( | |
| dem, | ||
| tCPU, | ||
| frictType, | ||
| entrType, | ||
| resistanceType, | ||
| reportAreaInfo, | ||
|
fso42 marked this conversation as resolved.
|
||
| ): | ||
|
|
@@ -2744,6 +2757,8 @@ def computeEulerTimeStep( | |
| computation time dictionary | ||
| frictType: int | ||
| indicator for chosen type of friction model | ||
| entrType: int | ||
| indicator for chosen type of entrainment model | ||
| resistanceType: int | ||
| identifier for chosen type of resistance model | ||
|
|
||
|
|
@@ -2776,7 +2791,7 @@ def computeEulerTimeStep( | |
| startTime = time.time() | ||
| # loop version of the compute force | ||
| log.debug("Compute Force C") | ||
| particles, force, fields = DFAfunC.computeForceC(cfg, particles, fields, dem, frictType, resistanceType) | ||
| particles, force, fields = DFAfunC.computeForceC(cfg, particles, fields, dem, frictType, entrType, resistanceType) | ||
| tCPUForce = time.time() - startTime | ||
| tCPU["timeForce"] = tCPU["timeForce"] + tCPUForce | ||
| # compute lateral force (SPH component of the calculation) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -476,11 +476,23 @@ forestThMin = 0.6 | |
| forestVMax = 40. | ||
| forestThMax = 10. | ||
|
|
||
| #++++++++++++ Entrainment Model | ||
| ### Available Models: | ||
| #avaframe | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename to samosAT |
||
| #tjem | ||
| entrModel = avaframe | ||
|
|
||
| #++++++++++++ Entrainment Erosion Energy | ||
| # Used to determine speed loss via energy loss due to entrained mass | ||
| # Used to determine speed loss via energy loss due to entrained mass when using Avaframe Entrainment Model | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add units |
||
| # Select entEroEnergy = 0 to enable frontal plowing; entEroEnergy > 0 means basal erosion (without frontal plowing) | ||
| entEroEnergy = 5000 | ||
|
|
||
| #++++++++++++ Entrainment Shear Strength | ||
| # Used to determine the strength of the erodible snow cover when using TJEM Entrainment Model | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add units |
||
| entShearStrength = 500 | ||
|
|
||
| #++++++++++++Entrainment Energy loss | ||
| # Used to determine the energy loss because of entrainment | ||
| entShearResistance = 0 | ||
| entDefResistance = 0 | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changed tau has no effect! Tau is last used 19 lines up and not used anymore afterwards. So either drop the value and remove the code, or compute this here earlier in the code