Archive for the ‘Experiment’ Category

GenerativeComponents <-> EnergyPlus, connection (updated)

Wednesday, October 28th, 2009

These days I have been updated my GC<->E+ connection. I fix some bugs to get more speed, and I get it. you will see in the video 10 different thermal analysis of the box in less than a minute. so I’m glad for that. Unfortunly Since E+ needs some seconds to generate the new files, the speed in the evaluation has a limit.

Results: The data that you are viewing.
Inside Air temperature Average : is the average of the inside Air temeperature in the hottest and coldest day in Barcelona, this number should be the same all the time. 21 C degrees/hr.

Cooling Average : This is the jules/hourly that you have to spend in this building to keep the temperature at 21 C degrees. during the hottest and coldest day in the year. (this number must be change)

Heatting Average : This is the jules/hourly that you have to spend in this building to keep the temperature at 21 C degrees. during the hottest and coldest day in the year. (this number must be change)

The settings of the buildings, like the type of glass in windows, the material of walls or even the weather are defined in the E+ file.

GenerativeComponents <-> EnergyPlus, Connection (wip)

Saturday, October 24th, 2009

My PhD. is about Evolutionary Estrategies. More Precisely in Genetic Algorithms (GAs). I understand the GAs like a complex machine of optimization that knows nothing about the problem which it is trying to (re)solve.
This Particularity (detail) is very interesting, due to the fact that you can apply the GAs to different fields. For example, on the web you will find a lot of resources about GAs, such as Libraries of algorithms, examples of code, images and a lot of explanations.

The complex thing in a GA is not the programming part, as you can think, Is the way of how you define the problem that you want to optimize. This is usually a function called Fitness Function (FF). The correct set of your FF will determine the increase of the population’s level in each iteration. Therfore the effort must be put here.

The FF allows to evaluate each solution (individual) and to set who is who in the population, or in a different way, which of these solutions are the best and which are not.

Sometimes you can work with a really simple FF, like evaluating the length of a path, that you want to reduce. Besides, it can consists os a series of different equations that each individual must test. Logically, this process involve computational resources, it take some seconds or even minutes to achieve a correct evaluation.

In the case of one of my experiments, the evaluation consisted of determine how much energy a building spends in a specific weather. To achieve that I had to write a series of classes in C# (some of classes are built embedded in GC). Well a whole programme (with out interface, Console application) to allow me to transform the complete geometry in a different type of file for its thermal analysis in EnergyPlus.
GC_EP_post
This Video shows one of my first experiments in which I connect automatically (send and retrieve the data) GC and E+.

colaboration / flying surface

Friday, June 26th, 2009

This is a small colaboration with Mary ann busby, from chile.
the aim was generate surface from other surfaces, and create some kind movement.
the code works under recursion: analizing, generating and deleting every surface.
is very abstract and also is very simple how it’s works.

This movie requires Flash Player 9

Some Images from the complete generation, saving every “child”:

113

27

2-a-despues-del-crecimiento

35

r22

r12

r3-seccion-de-un-crecimiento

r21

And here the code:
some functions from Marius Watz:
Option Explicit
‘Script written by carlos de la b.
‘Script copyrighted by designemergente.org
‘Script version miércoles, 24 de junio de 2009 18:17:12

Call Main()
Sub Main()

‘//we need a Surface to grow and grow
Dim Idsrf
Idsrf = Rhino.GetObject(”sel srf”, 8)
If IsNull(Idsrf) Then Exit Sub

Call rec(Idsrf, 0)

End Sub

Function rec(Idsrf, counter) ‘//recursion under your own Risk!!!

‘domain of the curve
Dim Udom, Vdom
Udom = Rhino.SurfaceDomain(Idsrf, 0)
Vdom = Rhino.SurfaceDomain(Idsrf, 1)

‘parameters, divisions, counters and a point
Dim Up, Vp, divU, divV, i, j, k, pt, l
k = 0
divU = 6
divV = 6

Dim arrPoints(35)

For i = 0 To divU – 1
For j = 0 To divV – 1

Up = Udom(0) + i * ((Udom(1) – Udom(0)) / divU)
Vp = Vdom(0) + j * ((Vdom(1) – Vdom(0)) / divV)

pt = Rhino.SurfaceCurvature(Idsrf, Array(Up, Vp))

‘Randomize
‘ If 0.5 < rnd Then
‘ pt(1) = Rhino.VectorScale(pt(1), rnd * 5)
‘ l = Rhino.PointAdd(pt(1), pt(0))

‘ Else
l = Rhino.PointAdd(pt(1), pt(0))

‘ End If

arrPoints(k) = l
k = k + 1

Next
Next

Call Rhino.DeleteObject(IDsrf)
Dim n: n = Rhino.AddSrfPtGrid (Array(divU, divV), arrPoints)

Call Rhino.sleep(3000)

renderView()

Call rec(n, counter + 1)

End Function

‘ Render current viewport
Function renderView()’this function from Marius Watz, a very little modification by me.
Dim view,filename

view = Rhino.CurrentView
Rhino.Command “_-Render”
filename=getRenderFileName(”GrowSurface”)
Dim cmd : cmd=”_-SaveRenderWindowAs ” & Chr(34) & filename & Chr(34)
Rhino.Command cmd
Rhino.Command “_-CloseRenderWindow”
Rhino.Sleep(3000)
End Function

‘ Get auto-incremented filename
Function getRenderFileName(scriptName) ‘this function from Marius Watz
Dim index,done, doc, file, temp,imgNum

done=-1
index=0
Do While done=-1
doc=Rhino.WorkingFolder & “\” & scriptName & padStr(scriptName,index) & “.jpg”
file=Rhino.FindFile(doc)
If IsNull(file)=True Then
done=1
Else
index=index+1
End If
Loop

getRenderFileName=doc
End Function

Function padStr(prefix,val) ‘this function from Marius Watz
Dim l : l=Len(val)
If l<1 Then
padStr=”000″ & val
ElseIf l<2 Then
padStr=”00″ & val
ElseIf l<3 Then
padStr=”0″ & val
Else
padStr=”" & val
End If
End Function

Circle Packing

Wednesday, August 20th, 2008

I’ve been working yesterday in a Circle Packing, and I started with matsys pseudo-code.  I found a lot bugs, finally I decided to make a mixture between his algorithm and mine.  Circle Packing can be a very usefull algorithm and I think until now we have not seen their real power applied to architecture.

This is my little contribuition (pseudo_Code)

1_ Input: maxradius, boundary, iterations (not necessary the number of circles)

2_Add in a random position within the boundary a circle with maximum radius

3_Add a Random Point

4_If this Point is inside of the Circle just created, add another one and delete the old one

5_Add Line to this point (out of the circle) to the center of the circle, (here I use the same idea of matsys) “If the distance is greated than the maximum radius add a circle at that point with the maximum radius. If the distance is less than the maximum radius, add a circle at that point with the measured distance.”

6_ add another point and test if this point is within of any circle and add a line to every center circle to find the closest circle (step _5)

7_ repeat the steps 5  to 6 the number of the iterations

soon more images.

share, modify and send me an Image

best

Option Explicit
‘Script written by <Carlos de la Barrera>
‘Script copyrighted by <Carlos de la Barrera>

Call Main()
Sub Main()
Dim Pt, R
Pt = Array(rnd * 100, rnd * 100, 0)
R = FuncCir(Pt, 10)

Call Pack(R)
End Sub

Function Pack(R)
Dim Pt, i, count

count = Rhino.GetInteger(” number of circles “, 50, 2, 1000)
If IsNull (count) Then Exit Function

Dim ArrData()

For i = 0 To count
ReDim Preserve ArrData(i)
ArrData(i) = R

Pt = Array(Rnd * 100, rnd * 100, 0)

Dim j
Dim t: t = 0

For j = 0 To UBound(ArrData)
If Rhino.IsPointOnSurface(ArrData(j)(1)(0), Pt)Then
Call Rhino.print (”point in surface”)
t = t + 1

End If
Next

If (t = 0) Then
ReDim ArrLine(UBound(ArrData))
Dim k, line

For K = 0 To UBound(ArrData)
line = Rhino.AddLine(Pt, Rhino.CircleCenterPoint(ArrData(k)(0)))
ArrLine(k) = Line
Next

Dim d, d2, l
d = funcDist(Pt, ArrData(0)(0), ArrLine(0))

For l = 0 To UBound(ArrLine)
d2 = funcDist(Pt, ArrData(l)(0), ArrLine(l))

If d < d2 Then
‘Call Rhino.Print (”nothing”)

Else
d = d2

End If
Next

R = FuncCir(Pt, d)
Call Rhino.DeleteObjects (ArrLine)

End If
Next
End Function

Function FuncCir(p, D)

If D >= 10 Then
D = 10

End If

Dim plane
Dim R(1)

plane = Rhino.PlaneFromFrame(p, Array(1.0,0.0,0.0), Array(0.0,1.0,0.0))
R(0)   = Rhino.AddCircle(plane, D)
R(1) = Rhino.AddPlanarSrf(Array(R(0)))

FuncCir = R
End Function

Function funcDist(Pt, circleP, Line)
Dim Ap, j, d
Ap = Rhino.CurveCurveIntersection (circleP, Line)

For j = 0 To UBound(Ap)
d = Rhino.Distance(Pt, Ap(j, 1))
Next

funcDist = d
End Function

the other day I listen: – talk it’s easy,  ¡ show me the code ! -

Sensitive Analisys, Prato Italy

Wednesday, August 6th, 2008

I was invited to paticipate in a contest to the Comune di Prato in Italy. I have to say thank you to this cool group of architects from Lisboa: Duarte Cardoso Ferreira, Nuno Lobo Guerra, Ricardo Boaventura, Rita Frias Silva from ADOC architects and all the team of 4ARQ encharged of the 3D images.

I was encharge to develope by programming the plans and the general features of the school. We start working identify every tree in the ground and the area of the differents rooms for the school. Every tree was identify by a point and a minum area of influence (in the fisrt step of the algorithm) and each area of the room of the school was enter in to the algorithm to know the best performance of the build with out touch any tree.

Then the algorithm calculate a voronoi diagram (only with the trees) and inform the resultant areas and we could see where can “grow” our building. the next step was develope a second algorithm to generate pseudo-random points, between the trees and responding obviously to the influence area of them.

Then the process consist basicaly in create generations and test the results, if the dispositions of points allow build the school (first and more important test), if the result produce nice spaces, if we like it, if the algorithm respect entrance determined by us, etc. etc. after every generation, we pass again this second algorithm to produce in some points a random movement to explore new configurations and results.

I take this idea from Mutsuro Sasaki, he use an strategy based in the approach in successive steps to get the best result moving the points in pseudo random way.