Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoilCoolingDXMultiSpeed has methods to add stages, but none to remove stages #3990

Closed
jmarrec opened this issue Jun 3, 2020 · 3 comments · Fixed by #3996
Closed

CoilCoolingDXMultiSpeed has methods to add stages, but none to remove stages #3990

jmarrec opened this issue Jun 3, 2020 · 3 comments · Fixed by #3996

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Jun 3, 2020

Issue overview

CoilCoolingDXMultiSpeed has methods add stages, but none to remove stages

void addStage(CoilCoolingDXMultiSpeedStageData& stage);

Current Behavior

The API lets you add stages, but not remove them.

void addStage(CoilCoolingDXMultiSpeedStageData& stage);

Expected Behavior

You should be able to remove stages.

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): All
  • Version of OpenStudio (if using an intermediate build, include SHA): 3.0.1-beta1, f339397

Context

Found in #3987 (comment)

@jmarrec jmarrec changed the title CoilCoolingDXMultiSpeed has methods add stages, but none to remove stages CoilCoolingDXMultiSpeed has methods add to add stages, but none to remove stages Jun 3, 2020
@jmarrec jmarrec changed the title CoilCoolingDXMultiSpeed has methods add to add stages, but none to remove stages CoilCoolingDXMultiSpeed has methods to add stages, but none to remove stages Jun 3, 2020
@jmarrec
Copy link
Collaborator Author

jmarrec commented Jun 15, 2020

IDD should also add \max-fields since this object really expects two, three, or four speeds maximum.

@jmarrec
Copy link
Collaborator Author

jmarrec commented Jun 15, 2020

(availablitySchedule should have been non optional).

CoilCoolingDXMultiSpeedStageData is a ParentObject. It should have been a ResourceObject I think. @kbenne do you remember why you used ParentObject? cf 13473c0#diff-977d88f8d902362d07d5ae54eff635a6

Here's an example:

m = Model.new
dx = CoilCoolingDXMultiSpeed.new(m)
dx2 = CoilCoolingDXMultiSpeed.new(m)
stage = CoilCoolingDXMultiSpeedStageData.new(m)
dx.addStage(stage)
dx2.addStage(stage)
puts dx
OS:Coil:Cooling:DX:MultiSpeed,
  {3e17298c-7e78-4f13-8c94-5b7bf8113615}, !- Handle
  Coil Cooling DX Multi Speed 1,          !- Name
  [...]
  NaturalGas,                             !- Fuel Type
  {9c50af7f-34b2-4ef9-b691-c4f29b63130c}; !- Stage 1

Now remove dx2, and it deletes the stage in dx too:

dx2.remove
puts dx
OS:Coil:Cooling:DX:MultiSpeed,
  {7256b96e-11b7-439f-b040-95e4d70d6537}, !- Handle
  Coil Cooling DX Multi Speed 1,          !- Name
  [...]
  NaturalGas,                             !- Fuel Type
  ;                                       !- Stage 1

Anyways, this is probably besides the scope of this issue, so I'm going to leave it as is otherwise I'd have to modify a bunch of methods like clone, which may be surprising to users.

ModelObject CoilCoolingDXMultiSpeed_Impl::clone(Model model) const {
auto t_clone = StraightComponent_Impl::clone(model).cast<CoilCoolingDXMultiSpeed>();
auto t_stages = stages();
for( auto stage: t_stages ) {
auto stageClone = stage.clone(model).cast<CoilCoolingDXMultiSpeedStageData>();
t_clone.addStage(stageClone);
}
return t_clone;
}

@jmarrec
Copy link
Collaborator Author

jmarrec commented Jun 15, 2020

Well actually I think making it a ParentObject was the right call given this:

boost::optional<double> CoilCoolingDXMultiSpeedStageData_Impl::autosizedGrossRatedTotalCoolingCapacity() const {
auto indexAndNameOpt = stageIndexAndParentCoil();
boost::optional<double> result;
if (!indexAndNameOpt) {
return result;
}
auto indexAndName = indexAndNameOpt.get();
int index = std::get<0>(indexAndName);
CoilCoolingDXMultiSpeed parentCoil = std::get<1>(indexAndName);
std::string sqlField = "Design Size Speed " + std::to_string(index) + " Gross Rated Total Cooling Capacity";
return parentCoil.getAutosizedValue(sqlField, "W");
}

I suppose the issue is that a CoilCoolingDXMultiSpeedStageData shouldn't be used by more than one CoilCoolingDXMultiSpeed object.

jmarrec added a commit that referenced this issue Jun 15, 2020
* Add methods to remove stages, set by vector etc
* Constrain the number to maximum 4 stages per E+
* Ensure that a CoilCoolingDXMultiSpeedStageData can only be added to ONE CoilCoolingDXMultiSpeed
* When a CoilCoolingDXMultiSpeedStageData is removed, delete the corresponding extensible group in  CoilCoolingDXMultiSpeed if any
@tijcolem tijcolem added this to the OpenStudio SDK 3.1.0 milestone Jul 10, 2020
kbenne added a commit that referenced this issue Aug 10, 2020
Fix #3990 -  Add an API to CoilCoolingDXMultiSpeed to add/remove stages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants