Skip to content

Commit

Permalink
Update black (AMReX-Combustion#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf authored May 1, 2024
1 parent fffc8ea commit 13bdc93
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 54 deletions.
24 changes: 8 additions & 16 deletions Support/ceptr/ceptr/ck.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,7 @@ def ckpx(fstream, mechanism, species_info):
fstream,
"P = rho *"
f" {(cc.R * cc.ureg.kelvin * cc.ureg.mole / cc.ureg.erg).m:1.14e} * T"
" / XW; "
+ cw.comment("P = rho*R*T/W"),
" / XW; " + cw.comment("P = rho*R*T/W"),
)

cw.writer(fstream)
Expand Down Expand Up @@ -915,8 +914,7 @@ def ckpy(fstream, mechanism, species_info):
fstream,
"P = rho *"
f" {(cc.R * cc.ureg.kelvin * cc.ureg.mole / cc.ureg.erg).m:1.14e} * T"
" * YOW; "
+ cw.comment("P = rho*R*T/W"),
" * YOW; " + cw.comment("P = rho*R*T/W"),
)

cw.writer(fstream)
Expand Down Expand Up @@ -963,8 +961,7 @@ def ckpc(fstream, mechanism, species_info):
fstream,
"P = rho *"
f" {(cc.R * cc.ureg.kelvin * cc.ureg.mole / cc.ureg.erg).m:1.14e} * T"
" * sumC / W; "
+ cw.comment("P = rho*R*T/W"),
" * sumC / W; " + cw.comment("P = rho*R*T/W"),
)

cw.writer(fstream)
Expand Down Expand Up @@ -1003,8 +1000,7 @@ def ckrhox(fstream, mechanism, species_info):
fstream,
"rho = P * XW /"
f" ({(cc.R * cc.ureg.kelvin * cc.ureg.mole / cc.ureg.erg).m:1.14e} *"
" T); "
+ cw.comment("rho = P*W/(R*T)"),
" T); " + cw.comment("rho = P*W/(R*T)"),
)

cw.writer(fstream)
Expand Down Expand Up @@ -1036,8 +1032,7 @@ def ckrhoy(fstream, mechanism, species_info):
fstream,
"rho = P /"
f" ({(cc.R * cc.ureg.mole * cc.ureg.kelvin / cc.ureg.erg).m:1.14e} * T"
" * YOW);"
+ cw.comment("rho = P*W/(R*T)"),
" * YOW);" + cw.comment("rho = P*W/(R*T)"),
)

cw.writer(fstream, "}")
Expand Down Expand Up @@ -1419,8 +1414,7 @@ def ckxtcp(fstream, mechanism, species_info):
fstream,
"amrex::Real PORT ="
f" P/({(cc.R * cc.ureg.kelvin * cc.ureg.mole / cc.ureg.erg).m:1.14e} *"
" T); "
+ cw.comment("P/RT"),
" T); " + cw.comment("P/RT"),
)
# now compute conversion
cw.writer(fstream)
Expand Down Expand Up @@ -2130,8 +2124,7 @@ def ckwxp(fstream, mechanism, species_info):
fstream,
"amrex::Real PORT = 1e6 *"
f" P/({(cc.R * cc.ureg.kelvin * cc.ureg.mole / cc.ureg.erg).m:1.14e} *"
" T); "
+ cw.comment("1e6 * P/RT so c goes to SI units"),
" T); " + cw.comment("1e6 * P/RT so c goes to SI units"),
)

# now compute conversion
Expand Down Expand Up @@ -2568,8 +2561,7 @@ def ckkfkr(fstream, mechanism, species_info):
fstream,
"amrex::Real PORT = 1e6 *"
f" P/({(cc.R * cc.ureg.kelvin * cc.ureg.mole / cc.ureg.erg).m:1.14e} *"
" T); "
+ cw.comment("1e6 * P/RT so c goes to SI units"),
" T); " + cw.comment("1e6 * P/RT so c goes to SI units"),
)

# now compute conversion
Expand Down
52 changes: 30 additions & 22 deletions Support/ceptr/ceptr/species_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,14 @@ def make_scqss_dataframe(self):
lev_list.append(0)

# Initialize the dataframe
scqss_df = pd.DataFrame({
"name": name_list,
"number": numb_list,
"symbol": symb_list,
"level": lev_list,
})
scqss_df = pd.DataFrame(
{
"name": name_list,
"number": numb_list,
"symbol": symb_list,
"level": lev_list,
}
)

# Find the list of qss terms that have been filled
qss_filled = scqss_df["name"].unique()
Expand Down Expand Up @@ -230,12 +232,14 @@ def make_scqss_dataframe(self):
symb_list.append(symb)
lev_list.append(level)

scqss_df = pd.DataFrame({
"name": name_list,
"number": numb_list,
"symbol": symb_list,
"level": lev_list,
})
scqss_df = pd.DataFrame(
{
"name": name_list,
"number": numb_list,
"symbol": symb_list,
"level": lev_list,
}
)
qss_filled = scqss_df["name"].unique()

level += 1
Expand All @@ -262,11 +266,13 @@ def make_sc_dataframe(self):
symb_list.append(self.nonqssa_species_list[idx])

# Initialize the dataframe
sc_df = pd.DataFrame({
"name": name_list,
"number": numb_list,
"symbol": symb_list,
})
sc_df = pd.DataFrame(
{
"name": name_list,
"number": numb_list,
"symbol": symb_list,
}
)

sc_df["scqss_rely"] = ""
# Loop over the scqss_df and add in scqss dependence upon sc terms
Expand All @@ -293,11 +299,13 @@ def make_wdot_dataframe(self):
symb_list.append(self.nonqssa_species_list[idx])

# Initialize the dataframe
wdot_df = pd.DataFrame({
"name": name_list,
"number": numb_list,
"symbol": symb_list,
})
wdot_df = pd.DataFrame(
{
"name": name_list,
"number": numb_list,
"symbol": symb_list,
}
)

wdot_df["sc_dep"] = ""
wdot_df["scqss_dep"] = ""
Expand Down
38 changes: 23 additions & 15 deletions Support/ceptr/ceptr/symbolic_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,30 @@ def convert_to_cpp(self, sym_smp):

if self.remove_pow:
# Positive exponents
user_functions["Pow"].append((
lambda b, e: (e.is_Integer or e.is_Float)
and (abs(e - 1) < 1e-16 or abs(e - 2) < 1e-16 or abs(e - 3) < 1e-16),
lambda b, e: "(" + "*".join(["(" + b + ")"] * int(float(e))) + ")",
))
user_functions["Pow"].append(
(
lambda b, e: (e.is_Integer or e.is_Float)
and (
abs(e - 1) < 1e-16 or abs(e - 2) < 1e-16 or abs(e - 3) < 1e-16
),
lambda b, e: "(" + "*".join(["(" + b + ")"] * int(float(e))) + ")",
)
)
# Negative exponents
user_functions["Pow"].append((
lambda b, e: (e.is_Integer or e.is_Float)
and (abs(e + 1) < 1e-16 or abs(e + 2) < 1e-16 or abs(e + 3) < 1e-16),
lambda b, e: "("
+ "1.0/"
+ "("
+ "*".join(["(" + b + ")"] * int(-float(e)))
+ ")"
+ ")",
))
user_functions["Pow"].append(
(
lambda b, e: (e.is_Integer or e.is_Float)
and (
abs(e + 1) < 1e-16 or abs(e + 2) < 1e-16 or abs(e + 3) < 1e-16
),
lambda b, e: "("
+ "1.0/"
+ "("
+ "*".join(["(" + b + ")"] * int(-float(e)))
+ ")"
+ ")",
)
)

if self.remove_pow10:
user_functions["Pow"].append(
Expand Down
2 changes: 1 addition & 1 deletion Support/ceptr/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pyarrow = "^15.0.0"

[tool.poetry.dev-dependencies]
pytest = "^7.4.0"
black = {version = "^23.7.0"}
black = {version = "^24.3.0"}
isort = "^5.12.0"
ipython = "^8.14.0"
flake8 = "^4.0.1"
Expand Down

0 comments on commit 13bdc93

Please sign in to comment.