diff --git a/configs/analytical/reactions.json b/configs/analytical/reactions.json index b44350a3..72bbf553 100644 --- a/configs/analytical/reactions.json +++ b/configs/analytical/reactions.json @@ -1 +1,22 @@ -{"camp-data": [{"type": "MECHANISM", "name": "music box interactive configuration", "reactions": [{"type": "ARRHENIUS", "A": 0.00012, "B": 7, "C" : 75, "D": 50, "E": 0.5, "reactants": {"B": {"qty": 1}}, "products": {"C": {"yield": 1}, "irr__089f1f45-4cd8-4278-83d5-d638e98e4315": {"yield": 1}}}, {"type": "ARRHENIUS", "A": 0.004, "C" : 50, "reactants": {"A": {"qty": 1}}, "products": {"B": {"yield": 1}, "irr__2a109b21-bb24-41ae-8f06-7485fd36f1a7": {"yield": 1}}}]}]} \ No newline at end of file +{ + "camp-data": + [ + { + "type": "MECHANISM", + "name": "music box interactive configuration", + "reactions": + [ + { + "type": "ARRHENIUS", "A": 0.00012, "B": 7, "C" : 75, "D": 50, "E": 0.5, + "reactants": {"B": {"qty": 1}}, + "products": {"C": {"yield": 1}} + }, + { + "type": "ARRHENIUS", "A": 0.004, "C" : 50, + "reactants": {"A": {"qty": 1}}, + "products": {"B": {"yield": 1}} + } + ] + } + ] +} \ No newline at end of file diff --git a/configs/analytical/species.json b/configs/analytical/species.json index 58ede0a7..b2a1d060 100644 --- a/configs/analytical/species.json +++ b/configs/analytical/species.json @@ -1 +1,14 @@ -{"camp-data": [{"name": "A", "type": "CHEM_SPEC"}, {"name": "B", "type": "CHEM_SPEC"}, {"name": "C", "type": "CHEM_SPEC"}, {"name": "irr__089f1f45-4cd8-4278-83d5-d638e98e4315", "type": "CHEM_SPEC"}, {"name": "irr__2a109b21-bb24-41ae-8f06-7485fd36f1a7", "type": "CHEM_SPEC"}]} \ No newline at end of file +{ + "camp-data": + [ + { + "name": "A", "type": "CHEM_SPEC" + }, + { + "name": "B", "type": "CHEM_SPEC" + }, + { + "name": "C", "type": "CHEM_SPEC" + } + ] +} \ No newline at end of file diff --git a/python/wrapper.cpp b/python/wrapper.cpp index f1e0cf14..fc64b6ea 100644 --- a/python/wrapper.cpp +++ b/python/wrapper.cpp @@ -25,6 +25,7 @@ PYBIND11_MODULE(musica, m) "micm_solve", [](musica::MICM *micm, double time_step, double temperature, double pressure, py::list concentrations, py::object custom_rate_parameters = py::none()) { std::vector concentrations_cpp; + concentrations_cpp.reserve(len(concentrations)); for (auto item : concentrations) { concentrations_cpp.push_back(item.cast()); } @@ -32,18 +33,18 @@ PYBIND11_MODULE(musica, m) std::vector custom_rate_parameters_cpp; if (!custom_rate_parameters.is_none()) { py::list parameters = custom_rate_parameters.cast(); + custom_rate_parameters_cpp.reserve(len(parameters)); for (auto item : parameters) { custom_rate_parameters_cpp.push_back(item.cast()); } } - musica::Error error; musica::micm_solve(micm, time_step, temperature, pressure, concentrations_cpp.size(), concentrations_cpp.data(), custom_rate_parameters_cpp.size(), custom_rate_parameters_cpp.data(), &error); - // Update the concentrations list after solving + // Update the concentrations list after solving for (size_t i = 0; i < concentrations_cpp.size(); ++i) { concentrations[i] = concentrations_cpp[i]; } },