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

Develop #95

Merged
merged 4 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "HVAC_Temperature",
"forge_schema_spec": "autodesk.spec.aec.hvac:temperature-1.0.0",
"forge_schema_unit": "autodesk.unit.unit:fahrenheit-1.0.1",
"display": "CELSIUS"
"display": "FAHRENHEIT"
},
{
"type": "HVAC_TemperatureDifference",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
require_relative 'eplusout/models/engineering_check'
require_relative 'eplusout/models/estimated_peak_load_component'
require_relative 'eplusout/models/estimated_peak_load_component_table'
require_relative 'eplusout/models/location'
require_relative 'eplusout/models/peak_condition'

require_relative 'eplusout/mappers/mapper'
require_relative 'eplusout/mappers/coil_sizing_detail_mapper'
require_relative 'eplusout/mappers/engineering_check_mapper'
require_relative 'eplusout/mappers/estimated_peak_load_component_mapper'
require_relative 'eplusout/mappers/estimated_peak_load_component_table_mapper'
require_relative 'eplusout/mappers/location_mapper'
require_relative 'eplusout/mappers/peak_condition_mapper'

require_relative 'eplusout/relations/relation'
Expand All @@ -24,5 +26,6 @@
require_relative 'eplusout/relations/engineering_check_for_heatings'
require_relative 'eplusout/relations/estimated_cooling_peak_load_component_tables'
require_relative 'eplusout/relations/estimated_heating_peak_load_component_tables'
require_relative 'eplusout/relations/locations'

require_relative 'eplusout/container'
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def self.container(sql_file)
container.register(:engineering_check_for_heatings) { |c| Relations::EngineeringCheckForHeatings.new(c.sql_gateway) }
container.register(:estimated_cooling_peak_load_component_tables) { |c| Relations::EstimatedCoolingPeakLoadComponentTables.new(c.sql_gateway) }
container.register(:estimated_heating_peak_load_component_tables) { |c| Relations::EstimatedHeatingPeakLoadComponentTables.new(c.sql_gateway) }
container.register(:locations) { |c| Relations::Locations.new(c.sql_gateway) }

container
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module EPlusOut
module Mappers
class LocationMapper < EPlusOut::Mappers::Mapper

PARAM_MAP = [
{:index => 0, :name => :elevation, :type => 'double'},
{:index => 1, :name => :latitude, :type => 'double'},
{:index => 2, :name => :location_name, :type => 'string'},
{:index => 3, :name => :longitude, :type => 'double'},
{:index => 4, :name => :standard_pressure_at_elevation, :type => 'double'},
{:index => 5, :name => :standard_rhoair_at_elevation, :type => 'double'},
{:index => 6, :name => :time_zone_number, :type => 'double'}
]

private
def klass
EPlusOut::Models::Location
end

def param_map
PARAM_MAP
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module EPlusOut
module Models
Location = Struct.new(:name, :location_name, :latitude, :longitude, :time_zone_number, :elevation,
:standard_pressure_at_elevation, :standard_rhoair_at_elevation) do
include Models::Model
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module EPlusOut
module Relations
class Locations < Relation
def initialize(gateway, mapper = Mappers::LocationMapper.new)
super(gateway, mapper)
end

def name_field
:row_name
end

def clauses
{
table_name: "Site:Location"
}
end

def order_by
[:column_name]
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ def find_by_name(name)
end

def all
load if @instances.nil?
@instances
end

def first
load if @instances.nil?
@instances.values()[0]
end

private
def load
@instances = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
require_relative 'systems_analysis_report/mappers/sizing_factor_correction_peak_load_mapper'
require_relative 'systems_analysis_report/mappers/zone_load_summary_mapper'
require_relative 'systems_analysis_report/mappers/zone_estimated_peak_load_component_table_mapper'

require_relative 'systems_analysis_report/mappers/design_psychrometric_summary_mapper'
require_relative 'systems_analysis_report/mappers/design_psychrometric_mapper'

require_relative 'systems_analysis_report/models/model'
require_relative 'systems_analysis_report/models/cooling_and_heating'
require_relative 'systems_analysis_report/models/design_psychrometric'
require_relative 'systems_analysis_report/models/air_state_point'
require_relative 'systems_analysis_report/models/design_psychrometric_summary'
require_relative 'systems_analysis_report/models/peak_load_component'
require_relative 'systems_analysis_report/models/system_peak_load_component_table'
require_relative 'systems_analysis_report/models/report'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def self.container(model, sql_file)
container = Canister.new

container.register(:eplusout) { EPlusOut.container(sql_file) }
container.register(:design_psychrometric_repo) { |c| Repositories::DesignPsychrometricRepo.new(c.eplusout.coil_sizing_details) }
container.register(:design_psychrometric_repo) { |c| Repositories::DesignPsychrometricRepo.new(c.eplusout.coil_sizing_details, c.eplusout.locations) }
container.register(:zone_load_summary_repo) do |c|
Repositories::ZoneLoadSummaryRepo.new(
c.eplusout.cooling_peak_conditions,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module SystemsAnalysisReports
module Helpers
class Psychrometrics
def get_dew_point_from_vapor_pressure(t_dry_bulb, vapor_pressure)
dew_point = t_dry_bulb
log_vp = Math.log(vapor_pressure)

while true:

end
end

def get_vapor_pressure_from_humidity_ratio(humidity_ratio, pressure)
pressure * humidity_ratio / (0.621945 * humidity_ratio)
end

def get_dew_point_from_humidity_ratio(t_dry_bulb, humidity_ratio, pressure)
vapor_pressure = get_vapor_pressure_from_humidity_ratio(humidity_ratio, pressure)
get_dew_point_from_vapor_pressure(t_dry_bulb, vapor_pressure)
end

def get_wet_bulb_from_humidity_ratio(t_dry_bulb, humidity_ratio, pressure)
t_dew_point = get_t_dew_point_from_humidity_ratio(t_dry_bulb, humidity_ratio, pressure)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module SystemsAnalysisReport
module Mappers
class AirStatePointMapper < Mapper
def klass
Models::AirStatePoint
end

def mapping
[
# dry-bulb
# wet-bulb
#
# dew point
# Magnus Formula:
# y(Tdb, RH) = ln(RH/100) + b*Tdb/(c + Tdb)
# Tdp = cy(T, RH) / (b - y(T,RH))
# humidity ratio
# relative humdiity
# enthalpy
# specific heat
# density
# specific volume

[:zone_air_drybulb_at_ideal_loads_peak, :zone_dry_bulb_temperature],
[:zone_air_humidity_ratio_at_ideal_loads_peak, :zone_humidity_ratio],
[:zone_air_relative_humidity_at_ideal_loads_peak, :zone_relative_humidity],

[:system_return_air_drybulb_at_ideal_loads_peak, :return_air_dry_bulb_temperature],
[:system_return_air_humidity_ratio_at_ideal_loads_peak, :return_air_humidity_ratio],

[:outdoor_air_drybulb_at_ideal_loads_peak, :outdoor_air_dry_bulb_temperature],
[:outdoor_air_humidity_ratio_at_ideal_loads_peak, :outdoor_air_humidity_ratio],
[:outdoor_air_wet_bulb_at_ideal_loads_peak, :outdoor_air_wet_bulb_temperature],

[:coil_entering_air_drybulb_at_ideal_loads_peak, :entering_coil_dry_bulb_temperature],
[:coil_entering_air_humidity_ratio_at_ideal_loads_peak, :entering_coil_humidity_ratio],
[:coil_entering_air_enthalpy_at_ideal_loads_peak, :entering_coil_enthalpy],
[:coil_entering_air_wetbulb_at_ideal_loads_peak, :entering_coil_wet_bulb_temperature],

[:coil_leaving_air_drybulb_at_ideal_loads_peak, :leaving_coil_dry_bulb_temperature],
[:coil_leaving_air_humidity_ratio_at_ideal_loads_peak, :leaving_coil_humidity_ratio],
[:coil_leaving_air_enthalpy_at_ideal_loads_peak, :leaving_coil_enthalpy],
[:coil_leaving_air_wetbulb_at_ideal_loads_peak, :leaving_coil_wet_bulb_temperature],

[:standard_air_density_adjusted_for_elevation, :air_density],
[:moist_air_heat_capacity, :air_specific_heat],
[:outdoor_air_flow_percentage_at_ideal_loads_peak, :percent_outdoor_air],
[:outdoor_air_volume_flow_rate_at_ideal_loads_peak, :outdoor_air_flow_rate],
[:coil_sensible_capacity_at_ideal_loads_peak, :zone_sensible_load],
[:coil_final_reference_air_volume_flow_rate, :coil_air_flow_rate],
[:date_time_at_sensible_ideal_loads_peak, :time_of_peak],
[:zone_air_relative_humidity_at_ideal_loads_peak, :zone_relative_humidity],
]
end

def relative_humidity(t_dry_bulb, hum_ratio, pressure)
vapor_pressure = vapor_pressure(hum_ratio, pressure,)
relative_humidity = relative_humidty_from_vapor_pressure(t_dry_bulb, vapor_pressure)
return relative_humidity
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
module SystemsAnalysisReport
module Mappers
class DesignPsychrometricMapper < Mapper
attr_accessor :design_psychrometric_summary_mapper

def initialize(design_psychrometric_summary_mapper=Mappers::DesignPsychrometricSummaryMapper.new)
@design_psychrometric_summary_mapper = design_psychrometric_summary_mapper
end

def klass
Models::DesignPsychrometric
end

def mapping
[
[:standard_air_density_adjusted_for_elevation, :air_density],
[:moist_air_heat_capacity, :air_specific_heat],
[:outdoor_air_flow_percentage_at_ideal_loads_peak, :percent_outdoor_air],
[:outdoor_air_volume_flow_rate_at_ideal_loads_peak, :outdoor_air_flow_rate],
[:coil_sensible_capacity_at_ideal_loads_peak, :zone_sensible_load],
[:coil_final_reference_air_volume_flow_rate, :coil_air_flow_rate],
[:date_time_at_sensible_ideal_loads_peak, :time_of_peak],
[:zone_air_drybulb_at_ideal_loads_peak, :zone_dry_bulb_temperature],
[:zone_air_humidity_ratio_at_ideal_loads_peak, :zone_humidity_ratio],
[:zone_air_relative_humidity_at_ideal_loads_peak, :zone_relative_humidity],
[:system_return_air_drybulb_at_ideal_loads_peak, :return_air_dry_bulb_temperature],
[:system_return_air_humidity_ratio_at_ideal_loads_peak, :return_air_humidity_ratio],
[:outdoor_air_drybulb_at_ideal_loads_peak, :outdoor_air_dry_bulb_temperature],
[:outdoor_air_humidity_ratio_at_ideal_loads_peak, :outdoor_air_humidity_ratio],
[:coil_entering_air_drybulb_at_ideal_loads_peak, :entering_coil_dry_bulb_temperature],
[:coil_entering_air_humidity_ratio_at_ideal_loads_peak, :entering_coil_humidity_ratio],
[:coil_leaving_air_drybulb_at_ideal_loads_peak, :leaving_coil_dry_bulb_temperature],
[:coil_leaving_air_humidity_ratio_at_ideal_loads_peak, :leaving_coil_humidity_ratio],
[:supply_fan_air_heat_gain_at_ideal_loads_peak, :supply_fan_temperature_difference]
]
end
def call(coil_sizing_detail, location)
result = klass.new

def call(from)
result = super(from)
fan_temp_diff = from.supply_fan_air_heat_gain_at_ideal_loads_peak / (from.supply_fan_maximum_air_mass_flow_rate *
from.moist_air_heat_capacity)
result.summary = @design_psychrometric_summary_mapper.(coil_sizing_detail, location)
result.entering_coil = Models::AirStatePoint.new(coil_sizing_detail.coil_entering_air_drybulb_at_ideal_loads_peak, coil_sizing_detail.coil_entering_air_humidity_ratio_at_ideal_loads_peak)
result.leaving_coil = Models::AirStatePoint.new(coil_sizing_detail.coil_leaving_air_drybulb_at_ideal_loads_peak, coil_sizing_detail.coil_leaving_air_humidity_ratio_at_ideal_loads_peak)
result.outdoor_air = Models::AirStatePoint.new(coil_sizing_detail.outdoor_air_drybulb_at_ideal_loads_peak, coil_sizing_detail.outdoor_air_humidity_ratio_at_ideal_loads_peak)
result.return_air = Models::AirStatePoint.new(coil_sizing_detail.system_return_air_drybulb_at_ideal_loads_peak, coil_sizing_detail.system_return_air_humidity_ratio_at_ideal_loads_peak)
result.zone = Models::AirStatePoint.new(coil_sizing_detail.zone_air_drybulb_at_ideal_loads_peak, coil_sizing_detail.zone_air_humidity_ratio_at_ideal_loads_peak)

result.supply_fan_temperature_difference = fan_temp_diff
result
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module SystemsAnalysisReport
module Mappers
class DesignPsychrometricSummaryMapper < Mapper
def klass
Models::DesignPsychrometricSummary
end

def mapping
[
[:coil_air_volume_flow_rate_at_ideal_loads_peak, :coil_air_flow_rate],
[:outdoor_air_volume_flow_rate_at_ideal_loads_peak, :outdoor_air_flow_rate],
[:outdoor_air_flow_percentage_at_ideal_loads_peak, :percent_outdoor_air],
[:date_time_at_sensible_ideal_loads_peak, :time_of_peak],
[:coil_sensible_capacity_at_ideal_loads_peak, :zone_sensible_load],
]
end

def call(coil_sizing_detail, location)
result = super(coil_sizing_detail)

fan_temp_diff = coil_sizing_detail.supply_fan_air_heat_gain_at_ideal_loads_peak / (coil_sizing_detail.supply_fan_maximum_air_mass_flow_rate *
coil_sizing_detail.moist_air_heat_capacity)
result.supply_fan_temperature_difference = fan_temp_diff

result.atmospheric_pressure = location.standard_pressure_at_elevation

result
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module SystemsAnalysisReport
module Models
AirStatePoint = Struct.new(:dry_bulb_temperature, :humidity_ratio) do
include Models::Model

def validate

end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
require_relative 'model'
module SystemsAnalysisReport
module Models
DesignPsychrometric = Struct.new(:name, :air_density, :air_specific_heat, :percent_outdoor_air, :outdoor_air_flow_rate,
:zone_sensible_load, :coil_air_flow_rate, :time_of_peak, :zone_dry_bulb_temperature,
:zone_humidity_ratio, :zone_relative_humidity, :return_air_dry_bulb_temperature,
:return_air_humidity_ratio, :outdoor_air_dry_bulb_temperature, :outdoor_air_humidity_ratio,
:entering_coil_dry_bulb_temperature, :entering_coil_humidity_ratio,
:leaving_coil_dry_bulb_temperature, :leaving_coil_humidity_ratio, :supply_fan_temperature_difference) do
DesignPsychrometric = Struct.new(:name, :summary, :entering_coil, :leaving_coil, :outdoor_air, :return_air, :zone) do

include Models::Model

Expand All @@ -16,4 +11,4 @@ def validate

end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module SystemsAnalysisReport
module Models
DesignPsychrometricSummary = Struct.new(:name, :atmospheric_pressure, :coil_air_flow_rate, :outdoor_air_flow_rate,
:percent_outdoor_air, :supply_fan_temperature_difference, :time_of_peak,
:zone_sensible_load) do
include Models::Model

def validate

end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ module Repositories
class DesignPsychrometricRepo
attr_reader :coil_sizing_details, :mapper

def initialize(coil_sizing_details, mapper=Mappers::DesignPsychrometricMapper.new)
def initialize(coil_sizing_details, locations, mapper=Mappers::DesignPsychrometricMapper.new)
@coil_sizing_details = coil_sizing_details
@locations = locations
@mapper = mapper
end

def find(name)
design_psychrometric = nil
coil_sizing_detail = @coil_sizing_details.find_by_name(name)
location = @locations.first

if coil_sizing_detail
design_psychrometric = @mapper.(coil_sizing_detail)
design_psychrometric = @mapper.(coil_sizing_detail, location)
design_psychrometric.name = name
end

Expand Down