[Plugin] Solar/daylight analysis (v0.98, 2013-08-11)
-
Daylight analysis using SketchUp has been more or less an interactive affair (turn on shadows, move the sliders, observe the light patterns), or it has required knowledge of external programs (Ecotect, Daysim, Radiance, etc.).
This plugin calculates the amount of sunlight (insolation) falling on a group of faces over the course of a year, relative to the max sunlight theoretically available under a clear sky with no shade structures. The result is the daylight factor -- a number between 0.00 (completely shaded all year long) and 1.00 (nothing blocking the sun). The plugin color-codes and labels the target faces to indicate their daylight factor.
(model by Mugur)
Basic mode:
Advanced mode:
Feature summary:
-
Sun positions are calculated for each hour, based on latitude and longitude
-
Calculates direct beam and diffuse irradiation (accounts for atmospheric scattering and ground-based reflectance)
-
Output can be written to a comma-separated file
-
Output can be in terms of solar irradiation (in watts per meter squared)
-
Shading structures selected by layer
-
Glass or semi-transparent faces selected by layer (user-input transmissivity)
Future enhancements: -
Ability to specify TMY3 weather file for solar insolation actually observedin v0.98 -
Optimize computation time
Some code was translated from other people’s work. Please see credits, plugin options, and more details in the documentation (updated 2013-08-11)
SimpleSolarStudy.pdf
This is still ‘beta’, so please try it out and give me some bug/improvement feedback!v0.98 Updated 2013-08-11
simple_solar_study_v098.rbv0.98 Updated 2013-08-11
.rb and help files (.html and .pdf)
Test model -
-
I've used the sample model and get the attached error.
But a nice plugin idea!
-
'Brain
This IS a good idea...
BUT...
Your code actually changes the native SketchUp Numeric class [ill-advised - although I realize you inherited it from someone else!***].
The native Numeric class already has.radians
and.degrees
built in, to convert values 'to_deg' and 'to_rad' respectively.
Please recode to avoid this mess...
It is relatively straightforward to use Notepad++'s find/replace and then remove the unneeded class additions...Some tools are 'blacklisted' because of this kind of issue... including ***Gabriel Miller's
Sunpositon.rb
which is known to cause crashes with innocent tools like Fredo's CurviLoft !Also learn to use
__FILE__
to get where the file is loading from [you already use it when setting up the menu].
using thefind_support_file
method stops users from loading your plugin from their own custom-plugins folder...
So...
help_file = "Plugins/Simple_Solar_Study/help.html" hf = Sketchup.find_support_file "help.html", "Plugins/Simple_Solar_Study/" if {hf)...
would be better if recast as:
help_file = "../Simple_Solar_Study/help.html" hf = File.join(File.dirname(__FILE__), "Simple_Solar_Study", "help.html") if File.exist?(hf)...
-
Can't wait to try it...
-
Thanks for the feedback and for bearing with me. First SketchUp plugin (and first time coding in Ruby, for that matter! My background is C/C++, Perl and PHP).
I've updated the original post with the new code.
-
I posted a new version (see original post for files to download). Recent changes:
` %(#00BF00)[# Rev. | .Date..... | Notes
-----|------------|-----------------------------------
0.98 | 2013-08-11 | Add ability to read weather data from TMY3 file
.... | .......... | Bug: in fine/tmy3 mode, adjust for surface tilt
.... | .......... | based on beam strength on horiz. surface, not to
.... | .......... | normal-to-beam surface
0.97 | 2013-08-07 | Bug: remove Numeric class overloads, make help
.... | .......... | file search relative]`
The enhancement in v0.98 lets you calculate the daylight factor as a ratio of observed weather to clear sky (Bird-Hulstrum model). So for example, this is the clear sky expectation over the course of a year for some geometry geolocated in Seattle, Washington (note the max daylight factor appearing in the bottom left corner area):
Using a weather file from Seattle, the daylight factor looked like this:
In other words, over a typical year the cloud cover allows only 78% of the theoretical maximum sunlight reaching a horizontal surface.
Contrast that with the same geometry geolocated to Phoenix, Arizona. This is the daylight factor using the Phoenix TMY3 weather file. Very little cloud cover.
In TMY3 mode (a.k.a weather file), I could also have displayed the results in terms of watts per square meter, to get an idea of the amount of solar energy I could capture with a photovoltaic array. Note, however, that you would have to factor in PV efficiency (or inefficiency).
It should also be noted that the computations currently take a while. The above test uses really simple geometry. Here is what is being calculated:
- triangulated network of 96 faces to analyze
- 27 faces make up the shading structure
- analyzed from Jan 1 through Dec 31
- run on a laptop with a core2 duo processor @2.26Ghz, 32 bit OS, 3GB ram
and it takes 126 secondsto crunch.
Hence the need for this plugin:
http://sketchucation.com/forums/viewtopic.php?f=323&t=53685.Profiling the code when it's trying to simulate a run of 15 days showed the following:
% cumulative self self total time seconds seconds calls ms/call ms/call name 41.80 285.60 285.60 660648 0.43 0.60 BM_SimpleSolarStudy.inShadow 20.81 427.80 142.20 81464 1.75 23.65 Range#each 5.69 466.65 38.84 2404861 0.02 0.02 Array#[] 3.80 492.60 25.96 59682 0.43 0.78 BM_SimpleSolarStudy.adjustForTilt 1.89 505.49 12.88 660648 0.02 0.02 Geom.intersect_line_plane 1.81 517.84 12.36 660648 0.02 0.02 Sketchup;;Face#plane 1.70 529.47 11.63 660857 0.02 0.02 String#to_i 1.68 540.93 11.46 660648 0.02 0.02 Sketchup;;Face#classify_point 1.66 552.26 11.33 660648 0.02 0.02 Geom;;Point3d#- 1.63 563.41 11.15 661263 0.02 0.02 Hash#[] 1.62 574.51 11.10 662207 0.02 0.02 Fixnum#== 1.58 585.31 10.80 662137 0.02 0.02 Kernel.nil? 1.53 595.79 10.48 660853 0.02 0.02 Fixnum#& 1.51 606.14 10.35 661345 0.02 0.02 Fixnum#> 1.49 616.29 10.15 660648 0.02 0.02 Sketchup;;Drawingelement#hidden? 1.40 625.85 9.56 144037 0.07 0.10 Numeric#to_rad 0.98 632.53 6.68 203 32.89 32.89 Sketchup;;Drawingelement#material= 0.91 638.75 6.22 660851 0.01 0.01 Kernel.== 0.80 644.20 5.45 388599 0.01 0.01 Float#* 0.71 649.05 4.85 63402 0.08 0.10 Numeric#to_deg 0.62 653.26 4.22 119364 0.04 0.05 Geom;;Vector3d#new 0.61 657.43 4.16 744 5.60 13.40 BM_SimpleSolarStudy;;SSS_sunData#calcSun
Advertisement