Skip to content

Commit

Permalink
Fixed minor error for 'AddPeriodicControllers'.
Browse files Browse the repository at this point in the history
  • Loading branch information
csdechant committed Nov 7, 2024
1 parent 79b16cb commit 868f397
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions include/actions/AddPeriodicControllers.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AddPeriodicControllers : public Action
Real _start_time;
Real _period;
Real _cycles_per_controls;
Real _cycles_between_controls;
Real _num_controller_set;
std::string _name;

Expand Down
43 changes: 24 additions & 19 deletions src/actions/AddPeriodicControllers.C
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ AddPeriodicControllers::validParams()
params.addParam<Real>(
"starting_cycle", 0.0, "The number of the cycles before starting the control scheme");
params.addRequiredParam<Real>("cycle_frequency", "The cycle's frequency in Hz");
params.addParam<Real>("cycles_per_controls",
1.0,
"The number of cycles that occurs during the controllers"
"(e.g. the number of cycles during the accelerations)");
params.addParam<Real>("cycles_between_controls",
1.0,
"The number of cycles between controllers"
Expand Down Expand Up @@ -100,7 +104,8 @@ AddPeriodicControllers::AddPeriodicControllers(const InputParameters & params)

_start_time((1. / getParam<Real>("cycle_frequency")) * getParam<Real>("starting_cycle")),
_period(1. / getParam<Real>("cycle_frequency")),
_cycles_per_controls(getParam<Real>("cycles_between_controls")),
_cycles_per_controls(getParam<Real>("cycles_per_controls")),
_cycles_between_controls(getParam<Real>("cycles_between_controls")),
_num_controller_set(getParam<Real>("num_controller_set")),
_name(getParam<std::string>("name"))
{
Expand Down Expand Up @@ -138,77 +143,77 @@ AddPeriodicControllers::act()
// The end time is start time plus 0.0001 times the period
for (MooseIndex(_enable_start) j = 0; j < _enable_start.size(); ++j)
{
_enable_start_start_time_index[j] = _start_time + _cycles_per_controls * _period * i;
_enable_start_start_time_index[j] = _start_time + (_cycles_between_controls + _cycles_per_controls) * _period * i;
_enable_start_end_time_index[j] =
_start_time + _cycles_per_controls * _period * i + (_period * 0.0001);
_start_time + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0001);
}

for (MooseIndex(_enable_during) j = 0; j < _enable_during.size(); ++j)
{
_enable_during_start_time_index[j] = _start_time + _cycles_per_controls * _period * i;
_enable_during_start_time_index[j] = _start_time + (_cycles_between_controls + _cycles_per_controls) * _period * i;
_enable_during_end_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i + (_period * 0.0001);
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0001);
}

// If control cycles are back to back, then enable_start and enable_end times would be the
// same, To avoid this, if cycles are back to back, then the enable_end starts at +
// 0.0001*period.
if (_cycles_per_controls == 1.0)
if (_cycles_between_controls == 1.0)
{
for (MooseIndex(_enable_end) j = 0; j < _enable_end.size(); ++j)
{
_enable_end_start_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i + (_period * 0.0001);
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0001);
_enable_end_end_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i + (_period * 0.0002);
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0002);
}
}
else
{
for (MooseIndex(_enable_end) j = 0; j < _enable_end.size(); ++j)
{
_enable_end_start_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i;
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i;
_enable_end_end_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i + (_period * 0.0001);
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0001);
}
}

for (MooseIndex(_disable_start) j = 0; j < _disable_start.size(); ++j)
{
_disable_start_start_time_index[j] = _start_time + _cycles_per_controls * _period * i;
_disable_start_start_time_index[j] = _start_time + (_cycles_between_controls + _cycles_per_controls) * _period * i;
_disable_start_end_time_index[j] =
_start_time + _cycles_per_controls * _period * i + (_period * 0.0001);
_start_time + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0001);
}

for (MooseIndex(_disable_during) j = 0; j < _disable_during.size(); ++j)
{
_disable_during_start_time_index[j] = _start_time + _cycles_per_controls * _period * i;
_disable_during_start_time_index[j] = _start_time + (_cycles_between_controls + _cycles_per_controls) * _period * i;
_disable_during_end_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i + (_period * 0.0001);
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0001);
}

// If control cycles are back to back, then disable_start and disable_end times would be the
// same, To avoid this, if cycles are back to back, then the disable_end starts at +
// 0.0001*period
if (_cycles_per_controls == 1.0)
if (_cycles_between_controls == 1.0)
{
for (MooseIndex(_disable_end) j = 0; j < _disable_end.size(); ++j)
{
_disable_end_start_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i + (_period * 0.0001);
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0001);
_disable_end_end_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i + (_period * 0.0002);
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0002);
}
}
else
{
for (MooseIndex(_disable_end) j = 0; j < _disable_end.size(); ++j)
{
_disable_end_start_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i;
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i;
_disable_end_end_time_index[j] =
(_start_time + _period) + _cycles_per_controls * _period * i + (_period * 0.0001);
(_start_time + _period * _cycles_per_controls) + (_cycles_between_controls + _cycles_per_controls) * _period * i + (_period * 0.0001);
}
}

Expand Down

0 comments on commit 868f397

Please sign in to comment.