Skip to content

Commit

Permalink
Fixing CSVY Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSondhi committed Apr 28, 2021
1 parent 2c23d25 commit a8af420
Showing 1 changed file with 53 additions and 30 deletions.
83 changes: 53 additions & 30 deletions tardis/io/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def from_config_dict(cls, config_dict, validate=True, config_dirname=""):
if "csvy_model" in validated_config_dict.keys():
pass
elif "model" in validated_config_dict.keys():

# Model Section Validation
# Only Valid for Tardis Config File
# Not Valid for CSVY File Config
Expand Down Expand Up @@ -344,36 +345,58 @@ def from_config_dict(cls, config_dict, validate=True, config_dirname=""):
f"Inner Boundary Velocity = {v_inner_boundary} \n"
f"Outer Boundary Velocity = {v_outer_boundary}"
)

if model_section["structure"]["density"]["type"] == "exponential":
time_0 = model_section["structure"]["density"]["time_0"]
rho_0 = model_section["structure"]["density"]["rho_0"]
v_0 = model_section["structure"]["density"]["v_0"]
if not time_0.value > 0:
raise ValueError(f"Time Specified is Invalid, {time_0}")
if not rho_0.value > 0:
raise ValueError(f"Density Specified is Invalid, {rho_0}")
if not v_0.value > 0:
raise ValueError(f"Velocity Specified is Invalid, {v_0}")
elif model_section["structure"]["density"]["type"] == "power_law":
time_0 = model_section["structure"]["density"]["time_0"]
rho_0 = model_section["structure"]["density"]["rho_0"]
v_0 = model_section["structure"]["density"]["v_0"]
if not time_0.value > 0:
raise ValueError(f"Time Specified is Invalid, {time_0}")
if not rho_0.value > 0:
raise ValueError(f"Density Specified is Invalid, {rho_0}")
if not v_0.value > 0:
raise ValueError(f"Velocity Specified is Invalid, {v_0}")
elif model_section["structure"]["density"]["type"] == "uniform":
time_0 = model_section["structure"]["density"]["time_0"]
value = model_section["structure"]["density"]["value"]
if not time_0.value > 0:
raise ValueError(f"Time Specified is Invalid, {time_0}")
if not value.value > 0:
raise ValueError(
f"Density Value Specified is Invalid, {value}"
)
if "density" in model_section["structure"].keys():
if (
model_section["structure"]["density"]["type"]
== "exponential"
):
rho_0 = model_section["structure"]["density"]["rho_0"]
v_0 = model_section["structure"]["density"]["v_0"]
if not rho_0.value > 0:
raise ValueError(
f"Density Specified is Invalid, {rho_0}"
)
if not v_0.value > 0:
raise ValueError(
f"Velocity Specified is Invalid, {v_0}"
)
if "time_0" in model_section["structure"]["density"].keys():
time_0 = model_section["structure"]["density"]["time_0"]
if not time_0.value > 0:
raise ValueError(
f"Time Specified is Invalid, {time_0}"
)
elif (
model_section["structure"]["density"]["type"] == "power_law"
):
rho_0 = model_section["structure"]["density"]["rho_0"]
v_0 = model_section["structure"]["density"]["v_0"]
if not rho_0.value > 0:
raise ValueError(
f"Density Specified is Invalid, {rho_0}"
)
if not v_0.value > 0:
raise ValueError(
f"Velocity Specified is Invalid, {v_0}"
)
if "time_0" in model_section["structure"]["density"].keys():
time_0 = model_section["structure"]["density"]["time_0"]
if not time_0.value > 0:
raise ValueError(
f"Time Specified is Invalid, {time_0}"
)
elif model_section["structure"]["density"]["type"] == "uniform":
value = model_section["structure"]["density"]["value"]
if not value.value > 0:
raise ValueError(
f"Density Value Specified is Invalid, {value}"
)
if "time_0" in model_section["structure"]["density"].keys():
time_0 = model_section["structure"]["density"]["time_0"]
if not time_0.value > 0:
raise ValueError(
f"Time Specified is Invalid, {time_0}"
)

# SuperNova Section Validation
supernova_section = validated_config_dict["supernova"]
Expand Down

0 comments on commit a8af420

Please sign in to comment.