From f24f7c9d4e11a6878db8b87d142f673c07d21e23 Mon Sep 17 00:00:00 2001 From: Brandon Barker Date: Thu, 15 Feb 2024 18:40:36 +0000 Subject: [PATCH] docs: comments and formatting things --- src/sedov.py | 18 ++++++++++-------- src/test.py | 4 ++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/sedov.py b/src/sedov.py index 5742ac9..b3c8d27 100644 --- a/src/sedov.py +++ b/src/sedov.py @@ -112,7 +112,7 @@ def __init__(self, j, w, E, rho0, p0, gamma, t_end, r_model): self.Vstar = 2.0 / (self.j * (gamma - 1.0) + 2.0) # Eq 19 self.V0 = 2.0 / (gamma * j2w) # equation (23) - # Following Kamm & Timmes, introduce TOL in logic for determining solution family + # Following Kamm & Timmes, introduce TOL in logic for solution family # limits exponents later to not blow up TOL = 1.0e-5 self.family = Family.standard @@ -124,7 +124,7 @@ def __init__(self, j, w, E, rho0, p0, gamma, t_end, r_model): self.family = Family.singular else: raise ValueError( - "Something weird has happened: initial condition does not correspond to any solution family" + "Weird: initial condition does not correspond to any solution family" ) # Check for removable singularities @@ -150,8 +150,8 @@ def __init__(self, j, w, E, rho0, p0, gamma, t_end, r_model): self.e = (2.0 + j * (gamma - 1.0)) / 2.0 # Equations (42)-(47) - # The if logic below avoids divide by zero in the omega2, omega3 singularity cases. - # We avoid these singularities so no harm is done by modifying alpha2, alpha4, alpha5 + # Logic below avoids divide by zero in omega2, omega3 singularity cases. + # We avoid these singularities so no harm is done by modifying exponents denom2 = ( gamma * (self.w2 - w) if self.singularity != Singularity.omega2 else TOL ) @@ -244,14 +244,15 @@ def energy_integral_(self): return J1 and J2 energy integrals # the ennergy integrals can contain singularities at the lower bound. # for now, offset by machine epsilon to avoid. - # TODO: Implement singularity removal ala https://cococubed.com/papers/la-ur-07-2849.pdf + # TODO: Implement singularity removal ala + https://cococubed.com/papers/la-ur-07-2849.pdf # TODO: set Vmin appropriately """ self.J1 = 0.0 self.J2 = 0.0 self.alpha = 1.0 - if self.family == Family.singular: # singular case, integration is analytic + if self.family == Family.singular: # singular case self.J1 = (self.gamma + 1.0) / ( self.j * ((self.gamma - 1.0) * self.j + 2.0) ** 2.0 ) @@ -314,8 +315,9 @@ def lambda_(self, V): self similar function lambda depends on solution family See Kamm & Timmes section 2 - NOTE: The singular case is missing a factor of radius, because it's a pain to - pull through all of these functions. It's accounted for in other odd places. + NOTE: The singular case is missing a factor of radius. It's a pain to + pull through all of these functions. + It's accounted for in other odd places. """ eps = 1.0e-60 x1 = self.a * V diff --git a/src/test.py b/src/test.py index fefb5ca..928aaef 100644 --- a/src/test.py +++ b/src/test.py @@ -8,6 +8,7 @@ from sedov import Sedov +# === Helper functions for tests === def prepare_sedov_test(TMPDIR): """ @@ -117,6 +118,9 @@ def compare_sedov(x, rho, p, x_sol, rho_sol, p_sol): # End compare_sedov +# ================================= + + def test_sedov(): """ Test Sedov-Taylor against battle testing sedov3