Grasshopper

algorithmic modeling for Rhino

Hello everyone,

I'm making some hourly solar radiation simulations in a large geometry with more than 1000 individual buildings, so I'm calculating one building at a time. To do this, I created a "buildings" slider to select each building and run the solar radiation simulation and save the result into an excel file. It works, however it takes around 2 hours to compute radiation in all buildings, but I think there's nothing I can do about execution time.

The problem is that I would like to change the Analysis Period automatically and restart the "buildings" slider so that I don't have to check my computed every 2 hours, but I just can't figure out how...

For instance, suppose I want to calculate hourly solar radiation for the 21st of January, from 6am to 7 pm. It would be convenient if I could Animate the "hours" slider so that once the simulation for the last building was finished the "buildins" slider went to 0 again and the hour changed to 7. And so on...

Perhaps a small script with a basic cycle would solve the matter, but I still can't figure out to control the sliders as they have no input options.

Any ideas?

Thanks in advance!

And I'm sorry if this is a basic question or it has been discussed before (I'm new here and I didn't yet find similar discussion on this website).

Views: 2818

Replies to This Discussion

I tuned up my loops (they were off-by-one in iteration counts) and added an Expression to keep a history of the inner loop, showing the outer and inner loop counter values and the associated "Volume" for each one (corresponding to hours, buildings and solar radiation respectively).  It uses Anemone's 'Record data' and 'Output after the last' features...

time_bldg_2016_Jan6a.gh - "Classic" loops take ~44 seconds to go through 100 buildings 13 times (7am to 7pm, 0700 to 1900)

time_bldg_2016_Jan6b.gh - "Fast Loop" for the inner loop, "Classic" outer loop takes ~8 seconds to do the same thing!

time_bldg_2016_Jan6b.gh - "Fast Loop" for both inner and outer loops appears to take one or two seconds less but is hard to benchmark because you can't see anything happening.

(How does one do benchmarks in GH?)

Attachments:

Thank you so much for your prompt replies and interesting discussion!

I didn't know about Anemone.

I tried adapting the last suggestion by Joseph considering only 3 buildings, from 6am to 10am - here's a print screen of it (sorry for the poor quality!).

It seemed to work well, but I think I must be doing something wrong because my excel file was supposed to show 5 columns and 3 rows...

Attachments:

I can't tell without seeing the output that are going into Excel. Also what Excel writer are you using as they all work different?

Off the top of my head I think it might be overwriting the data as it does not now to put the info in the next cell/column.  

I'm using the excel writer "TT Toolbox". The output is just a number, which corresponds to the sum of solar radiation on all facades of each building.

It was writing fine before, when I had to change the hours manually... But I checked again if I was correctly telling the excel writer were to write, and yes I think it's ok: staring row is the building index plus 1 (I have one header line) and the columns is the hours minus 5, since I start in 6.

It must be something with the loops, it seems like it runs the 2nd loop only the first time. I guess I'll try skiping the Fast Loops as Joseph is saying, let's see...

Thank you!

You might want to skip the "Fast Loops" to start with because they are a little more tricky to get right, in my limited experience with them so far.  Use time_bldg_2016_Jan6a.gh as your pattern, making sure that 'Loop End' on the inner loop is set to "Output after the last".

You might need a third loop to traverse the faces of each building?

Or you might want to collect all your data as I did and write just one Excel file at the end?

Hard to know without having my hands on the code.  The looping idea is sound, it's just a matter of getting all the details correct.

P.S.  OH!  As I mentioned before, my loops were off-by-one in iteration counts and yours might be too.  For three buildings, the iteration count would be "2", not "3"?

Ok, I will try that. Thanks!

I don't need a third loop because I'm only interested in building facades and not roofs. I accidentally found that if I list all faces of a building they are selected in the same order, so it's easy to select only the vertical ones - that's why my definition as so many stuff inside the 2nd loop. Maybe there's a more elegant way of doing it, but it's not a problem at the moment.

Collecting all the data at the end is a good idea too, but it doesn't allow me to monitor the simulation so well since the canvas freezes most of the time.

Thank you so much for the hints! Let's see if I can get this right..

The "Classic" loops allow you to see what's happening while they are looping, the "Fast Loops" do not, which is precisely why I added code to record the values produced by the inner loop and spit them out at the end of the outer loop - so I could analyze what actually happened.

P.P.S.  Note the "x-1" expressions I added to the 'Repeat (N)' / 'Iterations (I)' inputs of my loop starts?  I didn't get even my simple example to work correctly until I collected all the history myself so I could understand what it was doing.  Especially true for "Fast Loops" where you can't see what's going on at all, only the end results.

Using two "classic" loops solved my problem, thank you so much!

However, the execution time increased exponentially with each new iteration if I tried to loop from 6am to 6pm at once. So I decided to execute in sets of 3 hours per loop (6-8am, 9-11am, and so on) and each iteration took around 1.5h, which made me check my computer fewer times. It works for now, but I'll have to find a more time-efficient way to do this in the future.

I will download Ladybug later and have a go with the code I posted using trampoline (as this code has little overheads as only records each time the hours changes in the code so should keep running fast to the end.) Only the Excel spreadsheet will record the data.

I have seen no evidence of exponential overhead with Anemone.  Must be something in the way you are using it...  Are you using 'Record data'?  How much data are you asking Anemone to record in each loop?  How many inner loop cycles per outer loop cycle?  Total number of cycles per hour?

The inner loop is set to "output after the last & record data", and does 1327 iterations (computes and records 1327 radiation values per loop, one value for each building, and writes them as a column to the excel file after the last iteration).

The outer loop is set to "constant output" and (I wished!) does 10 iterations, one for each hour from 6am to 6pm - it was going well for 6, 7 and 8, but 9 took twice the time, 10 almost half a day and I gave up on calculating 11am...). 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service