Class: ModifyEnergyPlusFanVariableVolumeObjects

Inherits:
OpenStudio::Measure::EnergyPlusMeasure
  • Object
show all
Defined in:
lib/measures/ModifyEnergyPlusFanVariableVolumeObjects/measure.rb

Overview

start the measure

Instance Method Summary collapse

Instance Method Details

#arguments(workspace) ⇒ Object

define the arguments that the user will input



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/measures/ModifyEnergyPlusFanVariableVolumeObjects/measure.rb', line 27

def arguments(workspace)
  args = OpenStudio::Measure::OSArgumentVector.new

  # make an argument
  pressureRise = OpenStudio::Measure::OSArgument.makeDoubleArgument('pressureRise', false)
  pressureRise.setDisplayName('Pressure Rise (Pa).')
  # pressureRise.setDefaultValue(10.76)
  args << pressureRise

  # make an argument
  maximumFlowRate = OpenStudio::Measure::OSArgument.makeDoubleArgument('maximumFlowRate', false)
  maximumFlowRate.setDisplayName('Maximum Flow Rate (m^3/s).')
  # maximumFlowRate.setDefaultValue(10.76)
  args << maximumFlowRate

  return args
end

#nameObject

define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml



22
23
24
# File 'lib/measures/ModifyEnergyPlusFanVariableVolumeObjects/measure.rb', line 22

def name
  return 'ModifyEnergyPlusFanVariableVolumeObjects'
end

#run(workspace, runner, user_arguments) ⇒ Object

define what happens when the measure is run



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/measures/ModifyEnergyPlusFanVariableVolumeObjects/measure.rb', line 46

def run(workspace, runner, user_arguments)
  super(workspace, runner, user_arguments)

  # use the built-in error checking
  if !runner.validateUserArguments(arguments(workspace), user_arguments)
    return false
  end

  # assign the user inputs to variables
  if !runner.getOptionalDoubleArgumentValue('pressureRise', user_arguments).empty?
    pressureRise = runner.getOptionalDoubleArgumentValue('pressureRise', user_arguments).get
  else
    pressureRise = nil
  end
  if !runner.getOptionalDoubleArgumentValue('maximumFlowRate', user_arguments).empty?
    maximumFlowRate = runner.getOptionalDoubleArgumentValue('maximumFlowRate', user_arguments).get
  else
    maximumFlowRate = nil
  end

  # check the pressureRise for reasonableness
  if pressureRise && (pressureRise < 0)
    runner.registerError('Please enter a non-negative value for Pressure Rise.')
    return false
  end

  # check the pressureRise for reasonableness
  if maximumFlowRate && (maximumFlowRate < 0)
    runner.registerError('Please enter a non-negative value for Maximum Flow Rate.')
    return false
  end

  # get all fanVariableVolumeObjects in model
  fanVariableVolumeObjects = workspace.getObjectsByType('Fan:VariableVolume'.to_IddObjectType)

  if fanVariableVolumeObjects.empty?
    runner.registerAsNotApplicable('The model does not contain any fanVariableVolumeObjects. The model will not be altered.')
    return true
  end
  puts "pressure rise: #{pressureRise}"
  fanVariableVolumeObjects.each do |fanVariableVolumeObject|
    fanVariableVolumeObject_name =  fanVariableVolumeObject.getString(0) # Name
    fanVariableVolumeObject_starting_pressureRise = fanVariableVolumeObject.getString(3) # Pressure Rise
    fanVariableVolumeObject_starting_maximumFlowRate = fanVariableVolumeObject.getString(4) # Maximum Flow Rate
    if pressureRise
      fanVariableVolumeObject.setString(3, pressureRise.to_s) # Pressure Rise
      runner.registerInfo("Changing pressure rise of #{fanVariableVolumeObject_name} from #{fanVariableVolumeObject_starting_pressureRise}(Pa) to #{fanVariableVolumeObject.getString(3)}(Pa).")
    end
    if maximumFlowRate
      fanVariableVolumeObject.setString(4, maximumFlowRate.to_s) # Maximum Flow Rate
      runner.registerInfo("Changing maximum flow rate of #{fanVariableVolumeObject_name} from #{fanVariableVolumeObject_starting_maximumFlowRate}(m^3/s) to #{fanVariableVolumeObject.getString(4)}(m^3/s).")
    end
  end

  # TODO: - add warning if a thermal zone has more than one fanVariableVolumeObjects object, as that may not result in the desired impact.

  # TODO: - may also want to warn or have info message for zones that dont have any fanVariableVolumeObjects

  # unique initial conditions based on
  # removed listing ranges for variable values since we are editing multiple fields vs. a single field.
  runner.registerInitialCondition("The building has #{fanVariableVolumeObjects.size} fanVariableVolumeObject objects.")

  # reporting final condition of model
  runner.registerFinalCondition("The building finished with #{fanVariableVolumeObjects.size} fanVariableVolumeObject objects.")

  return true
end