Skip to content

Commit

Permalink
Refactor output_pa.
Browse files Browse the repository at this point in the history
  • Loading branch information
studiospring committed Oct 6, 2015
1 parent 2f2cc55 commit a949d0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
10 changes: 1 addition & 9 deletions app/models/pv_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,11 @@ def add_all_panels_outputs
end

# Formula is approximation. Cannot confirm accuracy of result yet.
# Untested because factory is not set up correctly.
# http://math.stackexchange.com/questions/438766/volume-of-irregular-solid
# @return [Float] volume under graph (Wh).
def output_pa
total_volume = 0
const = volume_constant
self.column_heights.each do |column|
# vol = 0.25 * length_of_insolation_reading *
# readings_per_annual_increment * column.inject(:+)
total_volume += (const * column.inject(:+))
end
# convert to Wh
(total_volume * 3600).round
column_heights.reduce(0) { |a, col| a + (const * col.reduce(:+)) }.round
end

# TODO: check this formula!
Expand Down
16 changes: 14 additions & 2 deletions spec/models/pv_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,21 @@
end
end

# describe 'output_pa_array' do
# describe 'output_pa' do
# it "should return the volume under the graph" do
# expect(pv_query.output_pa_array).to eq('1234')
# expect(pv_query.output_pa).to eq(1789171)
# end
# end

# describe 'column_heights' do
# it "should return the volume under the graph" do
# expect(pv_query.column_heights).to eq(6441016320)
# end
# end
#
# describe 'volume_constant' do
# it 'should return the correct constant' do
# expect(pv_query.volume_constant).to eq(90.0)
# end
# end

Expand Down

0 comments on commit a949d0a

Please sign in to comment.