7#ifndef SVZERODSOLVER_SIMULATIONPARAMETERS_HPP_
8#define SVZERODSOLVER_SIMULATIONPARAMETERS_HPP_
11#include <nlohmann/json.hpp>
89 JsonWrapper(
const nlohmann::json& json,
const std::string& component,
90 const std::string& name_str,
const int&
id)
91 : nlohmann::json(json[component][id]),
104 if (!this->contains(key)) {
105 if (this->contains(name_str)) {
106 const std::string name = this->at(name_str);
107 throw std::runtime_error(
"Key " + std::string(key) +
108 " not found in element " + name +
109 " of component " + component);
111 throw std::runtime_error(
112 "Key " + std::string(key) +
" not found in element number " +
113 std::to_string(block_id) +
" of component " + component);
116 return this->at(key);
120 using nlohmann::json::contains;
121 using nlohmann::json::value;
122 using nlohmann::json::operator[];
125 std::string component;
126 std::string name_str;
144int generate_block(
Model& model,
const nlohmann::json& block_params_json,
145 const std::string& block_type,
const std::string_view& name,
146 bool internal =
false,
bool periodic =
true);
160std::unique_ptr<ActivationFunction> generate_activation_function(
161 Model& model,
const nlohmann::json& j,
const std::string& chamber_name);
175std::unique_ptr<SphereMaterial> generate_material(
176 const nlohmann::json& j,
const std::string& chamber_name);
190std::unique_ptr<ActiveStress> generate_active_stress(
191 const nlohmann::json& j,
const std::string& chamber_name);
200State load_initial_condition(
const nlohmann::json& config,
Model& model);
223void resolve_cardiac_cycle_period(
Model& model,
233void load_simulation_model(
const nlohmann::json& config,
Model& model);
240void validate_input(
const nlohmann::json& config);
254 std::vector<std::tuple<std::string, std::string>>& connections,
255 const nlohmann::json& config,
const std::string& component,
256 std::map<int, std::string>& vessel_id_map);
269void create_external_coupling(
271 std::vector<std::tuple<std::string, std::string>>& connections,
272 const nlohmann::json& config,
const std::string& component,
273 std::map<int, std::string>& vessel_id_map,
274 std::map<std::string, std::string>& bc_type_map);
286void create_boundary_conditions(
Model& model,
const nlohmann::json& config,
287 const std::string& component,
288 std::map<std::string, std::string>& bc_type_map,
289 std::vector<std::string>& closed_loop_bcs);
300void create_junctions(
302 std::vector<std::tuple<std::string, std::string>>& connections,
303 const nlohmann::json& config,
const std::string& component,
304 std::map<int, std::string>& vessel_id_map);
316void create_closed_loop(
318 std::vector<std::tuple<std::string, std::string>>& connections,
319 const nlohmann::json& config,
const std::string& component,
320 std::vector<std::string>& closed_loop_bcs);
332 std::vector<std::tuple<std::string, std::string>>& connections,
333 const nlohmann::json& config,
const std::string& component);
345 std::vector<std::tuple<std::string, std::string>>& connections,
346 const nlohmann::json& config,
const std::string& component);
Activation function classes for cardiac chamber models.
Active stress models for chamber blocks.
Material models for the ChamberSphere block.
const nlohmann::json & operator[](const char *key) const
Wrap error check around key retrieval (throws detailed error if key doesn't exist).
Definition SimulationParameters.h:103
JsonWrapper(const nlohmann::json &json, const std::string &component, const std::string &name_str, const int &id)
Wrap around JSON configuration with detailed error message in case key is not found in configuration.
Definition SimulationParameters.h:89
Model of 0D elements.
Definition Model.h:56
State of the system.
Definition State.h:19
Simulation parameters.
Definition SimulationParameters.h:40
bool sim_coupled
Running 0D simulation coupled with external solver.
Definition SimulationParameters.h:68
int sim_nliter
Definition SimulationParameters.h:56
bool output_all_cycles
Output all cardiac cycles.
Definition SimulationParameters.h:66
int sim_pts_per_cycle
Number of time steps per cardiac cycle.
Definition SimulationParameters.h:47
int sim_num_time_steps
Total number of time steps.
Definition SimulationParameters.h:55
double sim_external_step_size
Definition SimulationParameters.h:70
double sim_time_step_size
Simulation time step size.
Definition SimulationParameters.h:43
int sim_num_cycles
Number of cardiac cycles to simulate.
Definition SimulationParameters.h:46
bool output_mean_only
Output only the mean value.
Definition SimulationParameters.h:64
bool sim_max_iter_error_to_warning
Definition SimulationParameters.h:72
bool sim_steady_initial
Start from steady solution.
Definition SimulationParameters.h:61
int output_interval
Interval of writing output.
Definition SimulationParameters.h:59
bool output_variable_based
Output variable based instead of vessel based.
Definition SimulationParameters.h:62
double sim_abs_tol
Absolute tolerance for simulation.
Definition SimulationParameters.h:44
double sim_cardiac_period
Cardiac period.
Definition SimulationParameters.h:45
bool output_derivative
Output derivatives.
Definition SimulationParameters.h:65
double sim_cycle_to_cycle_error
Cycle-to-cycle error.
Definition SimulationParameters.h:54
bool use_cycle_to_cycle_error
Definition SimulationParameters.h:48
double sim_rho_infty
Spectral radius of generalized-alpha.
Definition SimulationParameters.h:58