quintel / etmoses

Online decision support tool to create local energy situations for neighbourhoods, cities and regions with a time resolution of 15 minutes created and maintained by Quintel – Not maintained
https://moses.energytransitionmodel.com
MIT License
11 stars 3 forks source link

All of a sudden change in Data HHP components #1376

Closed grdw closed 8 years ago

grdw commented 8 years ago

Related: #1262

I'm trying to split up the hybrid heat pump in components. However, I'm storing the data as such:

[
  ...
   {"buffer"=>"buffer_space_heating_1",
    "components"=>
     [{"type"=>"households_space_heater_hybrid_heatpump_air_water_electricity_electricity", "capacity"=>4.9, "performance_coefficient"=>4.5},
      {"type"=>"households_space_heater_hybrid_heatpump_air_water_electricity_gas", "capacity"=>"22.0", "performance_coefficient"=>1.067}],
    "composite"=>false,
    "concurrency"=>"max",
    "full_load_hours"=>1197,
    "initial_investment"=>"2481.0",
    "node"=>"Households 1",
    "om_costs_per_year"=>252.892561983471,
    "performance_coefficient"=>3.583,
    "sticks_to_composite"=>true,
    "technical_lifetime"=>15,
    "type"=>"households_space_heater_hybrid_heatpump_air_water_electricity",
    "units"=>1},
  ...
]

Which makes sense. This data is taken from a pry session:


    126: def technology_profile=(techs)
 => 127:   case techs
    128:     when Hash   then super(TechnologyList.from_hash(techs))
    129:     when String then super(TechnologyList.load(techs))
    130:     else             super
    131:   end
    132: end

However, when I check the content of the self.load method in TechnologyList something weird happened to the components...

 {"buffer"=>"buffer_space_heating_1",
    "capacity"=>nil,
    "composite"=>false,
    "composite_value"=>nil,
    "congestion_reserve_percentage"=>nil,
    "demand"=>nil,
    "position_relative_to_buffer"=>nil,
    "profile"=>nil,
    "type"=>"households_space_heater_hybrid_heatpump_air_water_electricity",
    "units"=>1,
    "volume"=>nil,
    "composite_index"=>nil,
    "concurrency"=>"max",
    "full_load_hours"=>1197,
    "initial_investment"=>2481.0,
    "om_costs_for_ccs_per_full_load_hour"=>nil,
    "om_costs_per_full_load_hour"=>nil,
    "om_costs_per_year"=>252.892561983471,
    "performance_coefficient"=>3.583,
    "technical_lifetime"=>15,
    "associates"=>[],
    "node"=>"Households 1",
    "profile_key"=>nil,
    "components"=>
     ["Hybrid heat pump space heating (electricity) (households_space_heater_hybrid_heatpump_air_water_electricity_electricity)",
      "Hybrid heat pump space heating (gas) (households_space_heater_hybrid_heatpump_air_water_electricity_gas)"]}, <-- Say, whaaat.

Taken from pry session point:

    12: def self.load(data)
 => 13:   binding.pry
    14:   data.blank? ? new({}) : from_hash(JSON.parse(data))
    15: end

Is there some step in between that does this (and automatically adds a load of attributes (I also don't know where for instance profile comes from)?). I'm sort of blindly assuming that the self.load comes directly after the part where I'm adding the technology_profile and that there are no steps in between.

antw commented 8 years ago

Looks like something is calling #to_s on the InstalledTechnology for the components?

InstalledTechnology.new(type: :households_space_heater_hybrid_heatpump_air_water_electricity_electricity).to_s
# => "Hybrid heat pump space heating (electricity) (households_space_heater_hybrid_heatpump_air_water_electricity_electricity)"
antw commented 8 years ago

Maybe here?

grdw commented 8 years ago

I found out what it was. There's a bit of a ping-pong going on when creating a LES. The technology_profile is first put into InstalledTechnology objects right here. Than it dumps again here and loads again (causing the actual problem). The issue was in the dumping part, that method turned the components into InstalledTechnology objects while it should've turned them into Hashes aswell.

Therefor closing this issue.