Dear all, now I am trying to modify the fuel type in Coil:Heating:Fuel with OpenStudio.
In my understanding, Coil:Heating:Gas was modified to Coil:Heating:Fuel in the current version of EP and OS have not prepare the input for fuel type.
So, I would like to modify the fuel type with OpenStudio measure (is this OK?).
Though I wrote the measure as below, it didn't work.
I think I don't understand so many things. So, any tips from you will be helpful.
# see the URL below for information on how to write OpenStudio measures
# http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/
# start the measure
class ChangeFuelTypeInCoilHeatingFuel < OpenStudio::Measure::ModelMeasure
# human readable name
def name
return "Change Fuel Type in Coil:Heating:Fuel"
end
# human readable description
def description
return "This measure is used to change the type of fuel in Coil:Heating:Fuel of HVAC. This is currently not supported in OS. In the interface, the component is named Coil:Heating:Gas."
end
# human readable description of modeling approach
def modeler_description
return "Now construction"
end
# define the arguments that the user will input
def arguments(workspace)
args = OpenStudio::Measure::OSArgumentVector.new
#The Name of the component
comp_name = OpenStudio::Measure::OSArgument.makeStringArgument("comp_name", true)
comp_name.setDisplayName("The name of component modified by this measure")
args << comp_name
# the type of fuel
vfuel_chs = OpenStudio::StringVector.new
vfuel_chs << "Gas"
vfuel_chs << "NaturalGas"
vfuel_chs << "Propane"
vfuel_chs << "FuelOil#1"
vfuel_chs << "FuelOil#2"
vfuel_chs << "Diesel"
vfuel_chs << "Gasoline"
vfuel_chs << "Coal"
vfuel_chs << "Steam"
vfuel_chs << "OtherFuel1"
vfuel_chs << "OtherFuel2"
fueltype = OpenStudio::Measure::OSArgument::makeChoiceArgument('fueltype',vfuel_chs,true)
fueltype.setDisplayName('Fuel type for Coil:Heating:Fuel(represented as Gas in the current OS)')
fueltype.setDescription('Choose the fuel type used in your system.')
fueltype.setDefaultValue("Gas")
args << fueltype
return args
end
# define what happens when the measure is run
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
comp_name = runner.getStringArgumentValue('comp_name',user_arguments)
fueltype = runner.getStringArgumentValue('fueltype', user_arguments)
# check the user_name for reasonableness
if comp_name.empty?
runner.registerError('Error')
return false
end
# modifying fuel type of idf
chgs = model.getCoilHeatingGases
chgs.each do |chg|
if CHG.name.get.match(comp_name)
CHG.setfuelType(fueltype)
end
end
runner.registerInfo("Completed.")
return true
end
end
# register the measure to be used by the application
ChangeFuelTypeInCoilHeatingFuel.new.registerWithApplication
The error message says
Applying ChangeFuelTypeInCoilHeatingFuel
Result: Fail
Error: undefined local variable or method `model' for #<ChangeFuelTypeInCoilHeatingFuel:0x00022952e03378>
C:/xxx/measure.rb:71:in `run'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.4/lib/openstudio/workflow/util/measure.rb:502:in `apply_measure'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.4/lib/openstudio/workflow/util/measure.rb:109:in `block in apply_measures'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.4/lib/openstudio/workflow/util/measure.rb:67:in `each_index'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.4/lib/openstudio/workflow/util/measure.rb:67:in `apply_measures'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.4/lib/openstudio/workflow/jobs/run_os_measures.rb:68:in `perform'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.4/lib/openstudio/workflow/run.rb:285:in `step'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.4/lib/openstudio/workflow/run.rb:232:in `run'
:/openstudio_cli.rb:975:in `execute'
:/openstudio_cli.rb:763:in `execute'
:/openstudio_cli.rb:1746:in `<main>'
eval:116:in `eval'
eval:116:in `require_embedded_absolute'
eval:101:in `block in require'
eval:95:in `each'
eval:95:in `require'
eval:3:in `<main>'
Failed.
Blockquote