Skip to content

Commit 8af5e00

Browse files
Auto-format code using Clang-Format, Prettier, autopep8, and JuliaFormatter (#756)
Co-authored-by: GitHub Actions <actions@github.com>
1 parent 8e8c738 commit 8af5e00

5 files changed

Lines changed: 40 additions & 24 deletions

File tree

‎include/musica/micm/parse.hpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ namespace musica
6767
bool ignore_non_gas_phases = false);
6868
Chemistry ParserV1(const mechanism_configuration::ParserResult<>& result);
6969

70-
mechanism_configuration::v1::types::Mechanism ConvertV0MechanismToV1(const std::string& config_path, bool convert_reaction_units = true);
70+
mechanism_configuration::v1::types::Mechanism ConvertV0MechanismToV1(
71+
const std::string& config_path,
72+
bool convert_reaction_units = true);
7173
mechanism_configuration::v1::types::Mechanism ConvertV0MechanismToV1(
7274
const mechanism_configuration::v0::types::Mechanism& v0_mechanism,
7375
bool convert_reaction_units = true);

‎python/bindings/mechanism_configuration/mechanism_configuration.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,11 @@ void bind_mechanism_configuration(py::module_ &mechanism_configuration)
492492
"parse_and_convert_v0",
493493
[](V1Parser &self, const std::string &path, bool convert_reaction_units)
494494
{
495-
mechanism_configuration::v1::types::Mechanism mechanism = musica::ConvertV0MechanismToV1(path, convert_reaction_units);
495+
mechanism_configuration::v1::types::Mechanism mechanism =
496+
musica::ConvertV0MechanismToV1(path, convert_reaction_units);
496497
return mechanism;
497498
},
498-
py::arg("path"), py::arg("convert_reaction_units") = true,
499+
py::arg("path"),
500+
py::arg("convert_reaction_units") = true,
499501
"Parse a v0 mechanism configuration file");
500502
}

‎python/musica/examples/ts1_box_model.py‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
initial_concentrations = conditions[conditions['parameter'].str.contains(
3737
'CONC')]
3838
# remove CONC. from the parameter names
39-
initial_concentrations.loc[:, 'parameter'] = initial_concentrations.loc[:, 'parameter'].str.replace('CONC.', '', regex=False)
39+
initial_concentrations.loc[:, 'parameter'] = initial_concentrations.loc[:,
40+
'parameter'].str.replace('CONC.', '', regex=False)
4041

4142
# grab the environmental conditions, anything prefixed with ENV.
4243
environmental_conditions = conditions[conditions['parameter'].str.contains('ENV')]
@@ -77,26 +78,26 @@
7778
times = [0]
7879
concentrations = [state.get_concentrations()]
7980
time_step = 30 # seconds
80-
simulation_length = 1 * 60 * 60 # 1 hour in seconds
81+
simulation_length = 1 * 60 * 60 # 1 hour in seconds
8182
current_time = 0
8283
last_printed_percent = -5 # Track last printed percentage
8384

8485
while current_time < simulation_length:
8586
elapsed = 0
8687
while elapsed < time_step:
87-
remaining_time = time_step - elapsed
88-
result = solver.solve(state, remaining_time)
89-
elapsed += result.stats.final_time
90-
current_time += result.stats.final_time
91-
if result.state != SolverState.Converged:
92-
print(f"Solver state: {result.state}, time: {current_time}")
93-
88+
remaining_time = time_step - elapsed
89+
result = solver.solve(state, remaining_time)
90+
elapsed += result.stats.final_time
91+
current_time += result.stats.final_time
92+
if result.state != SolverState.Converged:
93+
print(f"Solver state: {result.state}, time: {current_time}")
94+
9495
# Print progress every 5%
9596
current_percent = (current_time / simulation_length) * 100
9697
if int(current_percent // 5) * 5 > last_printed_percent:
9798
last_printed_percent = int(current_percent // 5) * 5
9899
print(f"Simulation progress: {last_printed_percent}%")
99-
100+
100101
times.append(current_time)
101102
concentrations.append(state.get_concentrations())
102103

‎python/musica/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def convert_configuration(logger, configuration, output_path):
8484
parser = musica.mechanism_configuration.Parser()
8585
# the mechanism configuration automatically converts pre exponential factors to SI units
8686
# so we don't need to convert units again here.
87-
convert_units=False
87+
convert_units = False
8888
mechanism = parser.parse_and_convert_v0(configuration, convert_units)
8989
mechanism.export(output_path)
9090

‎src/micm/convert_v0_to_v1.cpp‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ namespace musica
1717
// remove USER. SURF. PHOTO. from name
1818
std::string stripped_name = name;
1919
const std::string prefixes[] = { "USER.", "SURF.", "PHOTO." };
20-
for (const auto& prefix : prefixes) {
20+
for (const auto& prefix : prefixes)
21+
{
2122
if (stripped_name.find(prefix) == 0)
2223
{
2324
stripped_name = stripped_name.substr(prefix.length());
@@ -69,15 +70,18 @@ namespace musica
6970
const std::vector<mechanism_configuration::v0::types::Species>& v0_species);
7071

7172
mechanism_configuration::v1::types::Reactions convert_reactions_v0_to_v1(
72-
const mechanism_configuration::v0::types::Reactions& v0_reactions, bool convert_reaction_units);
73+
const mechanism_configuration::v0::types::Reactions& v0_reactions,
74+
bool convert_reaction_units);
7375

7476
std::vector<mechanism_configuration::v1::types::ReactionComponent> convert_reaction_components_v0_to_v1(
7577
const std::vector<mechanism_configuration::v0::types::ReactionComponent>& v0_components);
7678

7779
mechanism_configuration::v1::types::ReactionComponent convert_reaction_component_v0_to_v1(
7880
const mechanism_configuration::v0::types::ReactionComponent& v0_component);
7981

80-
mechanism_configuration::v1::types::Mechanism ConvertV0MechanismToV1(const std::string& config_path, bool convert_reaction_units)
82+
mechanism_configuration::v1::types::Mechanism ConvertV0MechanismToV1(
83+
const std::string& config_path,
84+
bool convert_reaction_units)
8185
{
8286
mechanism_configuration::v0::Parser parser;
8387
auto parsed = parser.Parse(config_path);
@@ -160,7 +164,8 @@ namespace musica
160164
}
161165

162166
mechanism_configuration::v1::types::Reactions convert_reactions_v0_to_v1(
163-
const mechanism_configuration::v0::types::Reactions& v0_reactions, bool convert_reaction_units)
167+
const mechanism_configuration::v0::types::Reactions& v0_reactions,
168+
bool convert_reaction_units)
164169
{
165170
mechanism_configuration::v1::types::Reactions v1_reactions;
166171

@@ -187,7 +192,8 @@ namespace musica
187192
v1_branched.reactants = convert_reaction_components_v0_to_v1(branched.reactants);
188193
v1_branched.alkoxy_products = convert_reaction_components_v0_to_v1(branched.alkoxy_products);
189194
v1_branched.nitrate_products = convert_reaction_components_v0_to_v1(branched.nitrate_products);
190-
v1_branched.X = convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_branched.reactants, branched.X) : branched.X;
195+
v1_branched.X =
196+
convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_branched.reactants, branched.X) : branched.X;
191197
v1_branched.Y = branched.Y;
192198
v1_branched.a0 = branched.a0;
193199
v1_branched.n = branched.n;
@@ -215,8 +221,10 @@ namespace musica
215221
mechanism_configuration::v1::types::Troe v1_troe;
216222
v1_troe.reactants = convert_reaction_components_v0_to_v1(troe.reactants);
217223
v1_troe.products = convert_reaction_components_v0_to_v1(troe.products);
218-
v1_troe.k0_A = convert_reaction_units ? k0_A_convert_molecules_cm3_to_moles_m3(v1_troe.reactants, troe.k0_A) : troe.k0_A;
219-
v1_troe.kinf_A = convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_troe.reactants, troe.kinf_A) : troe.kinf_A;
224+
v1_troe.k0_A =
225+
convert_reaction_units ? k0_A_convert_molecules_cm3_to_moles_m3(v1_troe.reactants, troe.k0_A) : troe.k0_A;
226+
v1_troe.kinf_A =
227+
convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_troe.reactants, troe.kinf_A) : troe.kinf_A;
220228
v1_troe.k0_B = troe.k0_B;
221229
v1_troe.k0_C = troe.k0_C;
222230
v1_troe.kinf_B = troe.kinf_B;
@@ -234,8 +242,10 @@ namespace musica
234242
mechanism_configuration::v1::types::TernaryChemicalActivation v1_ternary;
235243
v1_ternary.reactants = convert_reaction_components_v0_to_v1(ternary.reactants);
236244
v1_ternary.products = convert_reaction_components_v0_to_v1(ternary.products);
237-
v1_ternary.k0_A = convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_ternary.reactants, ternary.k0_A) : ternary.k0_A;
238-
v1_ternary.kinf_A = convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_ternary.reactants, ternary.kinf_A) : ternary.kinf_A;
245+
v1_ternary.k0_A =
246+
convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_ternary.reactants, ternary.k0_A) : ternary.k0_A;
247+
v1_ternary.kinf_A =
248+
convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_ternary.reactants, ternary.kinf_A) : ternary.kinf_A;
239249
v1_ternary.k0_B = ternary.k0_B;
240250
v1_ternary.k0_C = ternary.k0_C;
241251
v1_ternary.kinf_B = ternary.kinf_B;
@@ -253,7 +263,8 @@ namespace musica
253263
mechanism_configuration::v1::types::Tunneling v1_tunneling;
254264
v1_tunneling.reactants = convert_reaction_components_v0_to_v1(tunneling.reactants);
255265
v1_tunneling.products = convert_reaction_components_v0_to_v1(tunneling.products);
256-
v1_tunneling.A = convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_tunneling.reactants, tunneling.A) : tunneling.A;
266+
v1_tunneling.A =
267+
convert_reaction_units ? convert_molecules_cm3_to_moles_m3(v1_tunneling.reactants, tunneling.A) : tunneling.A;
257268
v1_tunneling.B = tunneling.B;
258269
v1_tunneling.C = tunneling.C;
259270
v1_tunneling.gas_phase = "gas";

0 commit comments

Comments
 (0)