Skip to content

Commit

Permalink
fixed some style issues and variable name selection
Browse files Browse the repository at this point in the history
  • Loading branch information
shakedregev committed Jan 16, 2025
1 parent fb88866 commit 3b6e568
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 83 deletions.
2 changes: 1 addition & 1 deletion ComponentLib/PowerElectronics/CircuitComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace ModelLib
}

/**
* @brief Create the mappings from local to global indexes
* @brief Create the mappings from local to global indices
*
* @param local_index
* @param global_index
Expand Down
4 changes: 2 additions & 2 deletions Examples/Microgrid/Microgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ int main(int argc, char const *argv[])
double abstol = 1.0e-8;
double reltol = 1.0e-8;
size_t max_step_amount = 3000;
bool usejac = true;
bool use_jac = true;

//Create model
ModelLib::PowerElectronicsModel<double, size_t>* sysmodel = new ModelLib::PowerElectronicsModel<double, size_t>(reltol, abstol, usejac, max_step_amount);
ModelLib::PowerElectronicsModel<double, size_t>* sysmodel = new ModelLib::PowerElectronicsModel<double, size_t>(reltol, abstol, use_jac, max_step_amount);

//Modeled after the problem in the paper
double RN = 1.0e4;
Expand Down
4 changes: 2 additions & 2 deletions Examples/RLCircuit/RLCircuit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ int main(int argc, char const *argv[])
{
double abstol = 1.0e-8;
double reltol = 1.0e-8;
bool usejac = true;
bool use_jac = true;

//TODO:setup as named parameters
//Create circuit model
ModelLib::PowerElectronicsModel<double, size_t>* sysmodel = new ModelLib::PowerElectronicsModel<double, size_t>(reltol, abstol, usejac);
ModelLib::PowerElectronicsModel<double, size_t>* sysmodel = new ModelLib::PowerElectronicsModel<double, size_t>(reltol, abstol, use_jac);

size_t idoff = 0;

Expand Down
4 changes: 2 additions & 2 deletions Examples/ScaleMicrogrid/ScaleMicrogrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int test(index_type Nsize, real_type error_tol, bool debug_output)
{
using namespace ModelLib;

bool usejac = true;
bool use_jac = true;

real_type t_init = 0.0;
real_type t_final = 1.0;
Expand All @@ -77,7 +77,7 @@ int test(index_type Nsize, real_type error_tol, bool debug_output)
// Create circuit model
auto* sysmodel = new PowerElectronicsModel<real_type, index_type>(reltol,
abstol,
usejac,
use_jac,
SCALE_MICROGRID_MAX_STEPS);

const std::vector<real_type>* true_vec = &answer_key_N8;
Expand Down
24 changes: 12 additions & 12 deletions PowerElectronicsModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ namespace ModelLib
rtol_ = 1e-4;
atol_ = 1e-4;
this->max_steps_ = 2000;
// By default not use jacobian
usejac_ = false;
// By default don't use the jacobian
use_jac_ = false;
}

/**
* @brief Constructor for the system model
*/
PowerElectronicsModel(double rt = 1e-4, double at = 1e-4, bool ju = false, IdxT msa = 2000) : ModelEvaluatorImpl<ScalarT, IdxT>(0, 0, 0)
PowerElectronicsModel(double rtol = 1e-4, double atol = 1e-4, bool use_jac = false, IdxT max_steps = 2000) : ModelEvaluatorImpl<ScalarT, IdxT>(0, 0, 0)
{
// Set system model tolerances from input
rtol_ = rt;
atol_ = at;
this->max_steps_ = msa;
// Can choose if to use jacobain
usejac_ = ju;
rtol_ = rtol;
atol_ = atol;
this->max_steps_ = max_steps;
// Can choose if to use jacobian
use_jac_ = use_jac;
}

/**
Expand All @@ -91,15 +91,15 @@ namespace ModelLib
}

/**
* @brief Will check if each component has jacobian avalible. If one doesn't then jacobain is false.
* @brief Will check if each component has jacobian avalible. If one doesn't have it, return false.
*
*
* @return true
* @return false
*/
bool hasJacobian()
{
if (!this->usejac_)
if (!this->use_jac_)
return false;

for (const auto &component : components_)
Expand Down Expand Up @@ -234,7 +234,7 @@ namespace ModelLib
{
component->evaluateJacobian();

// get references to local jacobain
// get references to local jacobian
std::tuple<std::vector<IdxT>&, std::vector<IdxT>&, std::vector<ScalarT>&> tpm = component->getJacobian().getEntries();
const auto& [r, c, v] = tpm;

Expand Down Expand Up @@ -325,7 +325,7 @@ namespace ModelLib
static constexpr IdxT neg1_ = static_cast<IdxT>(-1);

std::vector<component_type*> components_;
bool usejac_;
bool use_jac_;

}; // class PowerElectronicsModel

Expand Down
Loading

0 comments on commit 3b6e568

Please sign in to comment.