Skip to content

Commit 69b1459

Browse files
authored
Merge pull request #321 from LLNL/bugfix/PorosityDamage
Fix for porosity interaction with damage when starting with zero porosity
2 parents 9a039f7 + bfb5c1d commit 69b1459

7 files changed

+106
-77
lines changed

RELEASE_NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Notable changes include:
5858
* Bugfix for RZ solid CRKSPH with compatible energy.
5959
* Parsing of None string now always becomes None python type. Tests have been updated accordingly.
6060
* IO for checkpoints and visuzalization can now be properly turned off through SpheralController input options.
61+
* Fixed porosity model interaction with damage for zero porosity case.
6162
6263
Version v2024.06.1 -- Release date 2024-07-09
6364
==============================================

src/Damage/ProbabilisticDamagePolicy.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ update(const KeyType& key,
288288
const auto alpha = (*alphaPtr)(i);
289289
const auto DalphaDti = std::min(0.0, (*DalphaDtPtr)(i)); // Only allowed to grow damage, not reduce it.
290290
const auto phi0 = 1.0 - 1.0/alpha0;
291-
const auto DD13Dt_p = -FastMath::CubeRootHalley2(phi0)/(3.0 * pow(1.0 - (alpha - 1.0)*safeInv(alpha0 - 1.0) + Dtiny, 2.0/3.0) * (alpha0 - 1.0))*Dtiny1*DalphaDti;
292-
CHECK(DD13Dt_p >= 0.0);
291+
const auto DD13Dt_p = -FastMath::CubeRootHalley2(phi0)*safeInv(3.0 * pow(1.0 - (alpha - 1.0)*safeInv(alpha0 - 1.0) + Dtiny, 2.0/3.0) * (alpha0 - 1.0))*Dtiny1*DalphaDti;
292+
CHECK2(DD13Dt_p >= 0.0, "bad DD13Dt_p: " << DD13Dt_p);
293293
D113 = std::min(1.0, D113 + multiplier*DD13Dt_p);
294294
}
295295

src/Porosity/ShadowPalphaPorosity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(self,
7979
last_alphae = 0.0
8080
iter = 0
8181
def DalphaDP_elastic(P, alpha):
82-
h = 1.0 + (alpha - 1.0)*(c0min - cS0)/(cS0*(alphae - 1.0))
82+
h = 1.0 + (alpha - 1.0)*(c0min - cS0)/max(1.0e-20, cS0*(alphae - 1.0))
8383
return alpha*alpha/K0*(1.0 - 1.0/(h*h))
8484
while abs(alphae - last_alphae) > 1.0e-10 and iter < 1000:
8585
iter += 1

src/Porosity/computeHugoniotWithPorosity.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@ def __init__(self,
7676

7777
# Find alphae = alpha(Pe)
7878
self.alphae = alpha0 # Starting point
79-
last_alphae = 0.0
80-
iter = 0
81-
while abs(self.alphae - last_alphae) > 1.0e-15 and iter < 1000:
82-
iter += 1
83-
last_alphae = self.alphae
84-
self.alphae = scipy.integrate.solve_ivp(self.Dalpha_elasticDP,
85-
t_span = [self.P0, self.Pe],
86-
y0 = [self.alpha0],
87-
t_eval = [self.Pe]).y[0][0]
79+
if alpha0 > 1.0:
80+
last_alphae = 0.0
81+
iter = 0
82+
while abs(self.alphae - last_alphae) > 1.0e-15 and iter < 1000:
83+
iter += 1
84+
last_alphae = self.alphae
85+
self.alphae = scipy.integrate.solve_ivp(self.Dalpha_elasticDP,
86+
t_span = [self.P0, self.Pe],
87+
y0 = [self.alpha0],
88+
t_eval = [self.Pe]).y[0][0]
8889

8990
if self.alphat is None:
9091
self.alphat = self.alphae # Reduces to Eq 8 in Jutzi 2008
@@ -96,8 +97,8 @@ def __init__(self,
9697
return
9798

9899
def h(self, alpha):
99-
assert self.alphae > 1.0 and self.c0 < self.cS0, "alphae={}, c0={}, cS0={}".format(self.alphae, self.c0, self.cS0)
100-
return 1.0 + (alpha - 1.0)*(self.c0 - self.cS0)/(self.cS0*(self.alphae - 1.0))
100+
assert self.alphae >= 1.0 and self.c0 <= self.cS0, "alphae={}, c0={}, cS0={}".format(self.alphae, self.c0, self.cS0)
101+
return 1.0 + (alpha - 1.0)*(self.c0 - self.cS0)/max(1.0e-20, self.cS0*(self.alphae - 1.0))
101102

102103
def Dalpha_elasticDP(self, P, alpha):
103104
return alpha*alpha/self.K0*(1.0 - 1.0/self.h(alpha)**2)

tests/functional/Hydro/Noh/Noh-cylindrical-2d.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
# MFM
3838
#
3939
#ATS:mfm0 = test( SELF, "--mfm True --nRadial 100 --cfl 0.25 --nPerh 2.51 --graphics False --restartStep 20 --clearDirectories True --steps 100", label="Noh cylindrical MFM, nPerh=2.5", np=8, gsph=True)
40-
#ATS:mfm1 = testif(gsph0, SELF, "--mfm True --nRadial 100 --cfl 0.25 --nPerh 2.51 --graphics False --restartStep 20 --clearDirectories False --steps 60 --restoreCycle 40 --checkRestart True", label="Noh cylindrical MFM, nPerh=2.5, restart test", np=8, gsph=True)
40+
#ATS:mfm1 = testif(mfm0, SELF, "--mfm True --nRadial 100 --cfl 0.25 --nPerh 2.51 --graphics False --restartStep 20 --clearDirectories False --steps 60 --restoreCycle 40 --checkRestart True", label="Noh cylindrical MFM, nPerh=2.5, restart test", np=8, gsph=True)
4141
#
4242
# MFV
4343
#
4444
#ATS:mfv0 = test( SELF, "--mfv True --nRadial 100 --cfl 0.25 --nPerh 2.51 --graphics False --restartStep 20 --clearDirectories True --steps 100", label="Noh cylindrical MFV, nPerh=2.5", np=8, gsph=True)
45-
#ATS:mfv1 = testif(gsph0, SELF, "--mfv True --nRadial 100 --cfl 0.25 --nPerh 2.51 --graphics False --restartStep 20 --clearDirectories False --steps 60 --restoreCycle 40 --checkRestart True", label="Noh cylindrical MFV, nPerh=2.5, restart test", np=8, gsph=True)
45+
#ATS:mfv1 = testif(mfv0, SELF, "--mfv True --nRadial 100 --cfl 0.25 --nPerh 2.51 --graphics False --restartStep 20 --clearDirectories False --steps 60 --restoreCycle 40 --checkRestart True", label="Noh cylindrical MFV, nPerh=2.5, restart test", np=8, gsph=True)
4646

4747
#-------------------------------------------------------------------------------
4848
# The Cylindrical Noh test case run in 2-D.

tests/functional/Porosity/PlanarCompaction/PlanarCompaction-1d.py

+84-60
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#ATS:t1 = test( SELF, "--graphics False --clearDirectories True --checkError False --dataDirBase dumps-PlanarCompaction-1d-sph-restart --restartStep 100 --steps 200", label="Planar porous aluminum compaction problem -- 1-D (serial, restart test step 1)")
1414
#ATS:t2 = testif(t1, SELF, "--graphics False --clearDirectories False --checkError False --dataDirBase dumps-PlanarCompaction-1d-sph-restart --restartStep 100 --steps 100 --checkRestart True --restoreCycle 100 --postCleanup True", label="Planar porous aluminum compaction problem -- 1-D (serial, restart test step 2)")
1515
#
16+
# Ordinary SPH with no initial porosity
17+
#
18+
#ATS:t3 = testif(t0, SELF, "--alpha0 1.0 --useDamage False --goalTime 1.0 --graphics False --clearDirectories True --checkError True --dataDirBase dumps-PlanarCompaction-1d-sph --restartStep 100000 --postCleanup True", np=4, label="Planar porous aluminum compaction problem with no initial porosity -- 1-D (4 proc, no damage model)")
19+
#ATS:t4 = testif(t3, SELF, "--alpha0 1.0 --useDamage True --goalTime 1.0 --graphics False --clearDirectories True --checkError True --dataDirBase dumps-PlanarCompaction-1d-sph --restartStep 100000 --postCleanup True", np=4, label="Planar porous aluminum compaction problem with no initial porosity -- 1-D (4 proc, with damage model)")
20+
#
1621
# FSISPH
1722
#
1823
#ATS:t10 = test( SELF, "--graphics False --clearDirectories True --checkError True --hydroType FSISPH --dataDirBase dumps-PlanarCompaction-1d-fsisph --restartStep 100000 --postCleanup True", np=4, label="Planar porous aluminum compaction problem -- 1-D (FSISPH, 4 proc)", fsisph=True)
@@ -131,62 +136,81 @@
131136
#-------------------------------------------------------------------------------
132137
# The reference values for error norms checking for pass/fail
133138
#-------------------------------------------------------------------------------
134-
LnormRef = {"SPH": {"Mass density" : {"L1" : 0.06784186300927694,
135-
"L2" : 0.012774373437299643,
136-
"Linf" : 0.6245679444354701},
137-
"Spec Therm E" : {"L1" : 0.0001200742460791407,
138-
"L2" : 2.2616105613742583e-05,
139-
"Linf" : 0.0010923440797387786},
140-
"velocity " : {"L1" : 0.004921931042558655,
141-
"L2" : 0.0009173594117158436,
142-
"Linf" : 0.0448725433453345},
143-
"pressure " : {"L1" : 0.0022217375280911347,
144-
"L2" : 0.00039479153550769805,
145-
"Linf" : 0.018793913196205617},
146-
"alpha " : {"L1" : 0.0590391542763204,
147-
"L2" : 0.007963583413760916,
148-
"Linf" : 0.2738180402369801},
149-
"h " : {"L1" : 0.00043261838627472803,
150-
"L2" : 8.062946952637553e-05,
151-
"Linf" : 0.014201309070925212}},
152-
153-
"FSISPH": {"Mass density" : {"L1" : 0.06781314493410028,
154-
"L2" : 0.012767602580471844,
155-
"Linf" : 0.6245698198195724},
156-
"Spec Therm E" : {"L1" : 0.00011965457154529887,
157-
"L2" : 2.254867764655585e-05,
158-
"Linf" : 0.0010923441579020216},
159-
"velocity " : {"L1" : 0.004913235403786584,
160-
"L2" : 0.0009163181868064007,
161-
"Linf" : 0.044872645505280966},
162-
"pressure " : {"L1" : 0.002210222289968727,
163-
"L2" : 0.00039387994606202237,
164-
"Linf" : 0.018793847854203908},
165-
"alpha " : {"L1" : 0.05903530352469833,
166-
"L2" : 0.007960855343380124,
167-
"Linf" : 0.2738175996911776},
168-
"h " : {"L1" : 0.0004319674641541397,
169-
"L2" : 8.05536967933465e-05,
170-
"Linf" : 0.014201309071287523}},
171-
172-
"CRKSPH": {"Mass density" : {"L1" : 0.0679707220773017,
173-
"L2" : 0.012783621322270034,
174-
"Linf" : 0.6245687018640083},
175-
"Spec Therm E" : {"L1" : 0.0001201303520771047,
176-
"L2" : 2.2622550331357265e-05,
177-
"Linf" : 0.00109234444748564},
178-
"velocity " : {"L1" : 0.004926121368235753,
179-
"L2" : 0.0009173629106343205,
180-
"Linf" : 0.044872623201390446},
181-
"pressure " : {"L1" : 0.0022258225868044238,
182-
"L2" : 0.00039496818856079414,
183-
"Linf" : 0.018793890216913627},
184-
"alpha " : {"L1" : 0.05909030710035451,
185-
"L2" : 0.007965976598237856,
186-
"Linf" : 0.2738173870953471},
187-
"h " : {"L1" : 0.00043274827065262975,
188-
"L2" : 8.062817025125132e-05,
189-
"Linf" : 0.014201309070451522}},
139+
LnormRef = {("SPH", 1.275) : {"Mass density" : {"L1" : 0.06784186300927694,
140+
"L2" : 0.012774373437299643,
141+
"Linf" : 0.6245679444354701},
142+
"Spec Therm E" : {"L1" : 0.0001200742460791407,
143+
"L2" : 2.2616105613742583e-05,
144+
"Linf" : 0.0010923440797387786},
145+
"velocity " : {"L1" : 0.004921931042558655,
146+
"L2" : 0.0009173594117158436,
147+
"Linf" : 0.0448725433453345},
148+
"pressure " : {"L1" : 0.0022217375280911347,
149+
"L2" : 0.00039479153550769805,
150+
"Linf" : 0.018793913196205617},
151+
"alpha " : {"L1" : 0.0590391542763204,
152+
"L2" : 0.007963583413760916,
153+
"Linf" : 0.2738180402369801},
154+
"h " : {"L1" : 0.00043261838627472803,
155+
"L2" : 8.062946952637553e-05,
156+
"Linf" : 0.014201309070925212}},
157+
158+
("SPH", 1.0) : {"Mass density" : {"L1" : 0.005403187072834507,
159+
"L2" : 0.001992916969258407,
160+
"Linf" : 0.22292338017813007},
161+
"Spec Therm E" : {"L1" : 2.9770274733200942e-05,
162+
"L2" : 1.038711319331483e-05,
163+
"Linf" : 0.0010487495498077324},
164+
"velocity " : {"L1" : 0.001085888733217598,
165+
"L2" : 0.00040460303212683284,
166+
"Linf" : 0.04537793164974422},
167+
"pressure " : {"L1" : 0.0018074730403377138,
168+
"L2" : 0.0006629679859824688,
169+
"Linf" : 0.0730479929478202},
170+
"alpha " : {"L1" : 0.0,
171+
"L2" : 0.0,
172+
"Linf" : 0.0},
173+
"h " : {"L1" : 6.116234877070288e-05,
174+
"L2" : 3.0869281685704505e-05,
175+
"Linf" : 0.014204020975568329}},
176+
177+
("FSISPH", 1.275) : {"Mass density" : {"L1" : 0.06781314493410028,
178+
"L2" : 0.012767602580471844,
179+
"Linf" : 0.6245698198195724},
180+
"Spec Therm E" : {"L1" : 0.00011965457154529887,
181+
"L2" : 2.254867764655585e-05,
182+
"Linf" : 0.0010923441579020216},
183+
"velocity " : {"L1" : 0.004913235403786584,
184+
"L2" : 0.0009163181868064007,
185+
"Linf" : 0.044872645505280966},
186+
"pressure " : {"L1" : 0.002210222289968727,
187+
"L2" : 0.00039387994606202237,
188+
"Linf" : 0.018793847854203908},
189+
"alpha " : {"L1" : 0.05903530352469833,
190+
"L2" : 0.007960855343380124,
191+
"Linf" : 0.2738175996911776},
192+
"h " : {"L1" : 0.0004319674641541397,
193+
"L2" : 8.05536967933465e-05,
194+
"Linf" : 0.014201309071287523}},
195+
196+
("CRKSPH", 1.275) : {"Mass density" : {"L1" : 0.0679707220773017,
197+
"L2" : 0.012783621322270034,
198+
"Linf" : 0.6245687018640083},
199+
"Spec Therm E" : {"L1" : 0.0001201303520771047,
200+
"L2" : 2.2622550331357265e-05,
201+
"Linf" : 0.00109234444748564},
202+
"velocity " : {"L1" : 0.004926121368235753,
203+
"L2" : 0.0009173629106343205,
204+
"Linf" : 0.044872623201390446},
205+
"pressure " : {"L1" : 0.0022258225868044238,
206+
"L2" : 0.00039496818856079414,
207+
"Linf" : 0.018793890216913627},
208+
"alpha " : {"L1" : 0.05909030710035451,
209+
"L2" : 0.007965976598237856,
210+
"Linf" : 0.2738173870953471},
211+
"h " : {"L1" : 0.00043274827065262975,
212+
"L2" : 8.062817025125132e-05,
213+
"Linf" : 0.014201309070451522}},
190214
}
191215

192216
#-------------------------------------------------------------------------------
@@ -579,10 +603,10 @@ def epsX_from_alphaX(alphaX,
579603
Linf = Pn.gridpnorm("inf", xmin, xmax)
580604
print(f"{name}\t\t{L1} \t\t{L2} \t\t{Linf}")
581605

582-
if checkError and not (np.allclose(L1, LnormRef[hydroType][name]["L1"], tol, tol) and
583-
np.allclose(L2, LnormRef[hydroType][name]["L2"], tol, tol) and
584-
np.allclose(Linf, LnormRef[hydroType][name]["Linf"], tol, tol)):
585-
print("Failing Lnorm tolerance for ", name, (L1, L2, Linf), LnormRef[hydroType][name])
606+
if checkError and not (np.allclose(L1, LnormRef[(hydroType, alpha0)][name]["L1"], tol, tol) and
607+
np.allclose(L2, LnormRef[(hydroType, alpha0)][name]["L2"], tol, tol) and
608+
np.allclose(Linf, LnormRef[(hydroType, alpha0)][name]["Linf"], tol, tol)):
609+
print("Failing Lnorm tolerance for ", name, (L1, L2, Linf), LnormRef[(hydroType, alpha0)][name])
586610
failure = True
587611
sys.stdout.flush()
588612

tests/functional/Porosity/PlanarCompaction/PlanarCompactionSolution.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ def soundSpeed_solution(self, t,
145145
us, rhos, epss, Ps, alphas, ue, rhoe, epse, Pe, alphae, xs, xe, v1, h1, v2, h2 = self.waveProperties(t)
146146
def _soundSpeed(rhoi, epsi, alphai):
147147
cS0 = self.eos.soundSpeed(alphai*rhoi, epsi)
148-
return cS0 + (alphai - 1.0)/(self.alpha0 - 1.0)*(self.crushCurve.c0 - cS0)
148+
if self.alpha0 > 1.0:
149+
return cS0 + (alphai - 1.0)/(self.alpha0 - 1.0)*(self.crushCurve.c0 - cS0)
150+
else:
151+
return cS0
149152
c_s = _soundSpeed(rhos, epss, alphas)
150153
c_e = _soundSpeed(rhoe, epse, alphae)
151154
c_0 = self.crushCurve.c0

0 commit comments

Comments
 (0)