Skip to content

Commit

Permalink
Enhance StepFunctionPower component to allow multiple instances
Browse files Browse the repository at this point in the history
This allows including multiple instances of the StepFunctionPower
component on the same node by adding an `id` attribute. This
identifier is put into the component name (via the __str__ function).
The default `id` is an empty string for back-compatibility.
  • Loading branch information
taldcroft committed Jul 20, 2020
1 parent c3be177 commit 1bf6e69
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions xija/component/heat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,18 +1013,26 @@ def plot_data__time(self, fig, ax):

class StepFunctionPower(PrecomputedHeatPower):
"""
A class that applies a constant temperature shift only
after a certain point in time.
A class that applies a constant heat power shift only
after a certain point in time. The shift is 0.0 before
``time`` and ``P`` after ``time``.
:param model: parent model object
:param node: node name or object for which to apply shift
:param time: time of step function shift
:param P: size of shift in heat power (default=0.0)
:param id: str, identifier to allow multiple steps (default='')
"""
def __init__(self, model, node, time, P=0.0):
def __init__(self, model, node, time, P=0.0, id=''):
super(StepFunctionPower, self).__init__(model)
self.time = DateTime(time).secs
self.node = self.model.get_comp(node)
self.add_par('P', P, min=-10.0, max=10.0)
self.n_mvals = 1
self.id = id
self.add_par('P', P, min=-10.0, max=10.0)

def __str__(self):
return 'step_power__{0}'.format(self.node)
return f'step_power{self.id}__{self.node}'

def get_dvals_tlm(self):
"""Return an array of zeros => no activation of the heater.
Expand Down

0 comments on commit 1bf6e69

Please sign in to comment.