So some time ago I wrote a little code and it worked fine. Then I did some 
experiments, but I change everything back after that. However, it seems 
that something is broken in my code. I spent at least an hour to figure 
whats going on, but still can't figure it out. Can someone help me? Here is 
my code:

module Geometry
> export GeometryFunc
> type pores{Float64}
>     R::Float64
>     coords::Vector{Float64}
> end
> function GeometryFunc(L,phi,distribution)
>   V_avg = (4*pi/3)*sum((distribution[1,:].^3).*distribution[2,:])
>   N = round(Int,(L^3*log(1/(1-phi)))/V_avg)
>   lattice = Vector{pores}(N)
>   R_max = maximum(distribution[1,:])
>   for j=1:1:N
>       lattice[j]=pores(0.0,[0.0,0.0,0.0])
>   end
>     for i=1:1:N
>         lattice[i].coords = rand(3)*L
>         Q = rand()
>         if Q < distribution[2,1]
>             lattice[i].R = distribution[1,1]
>         else
>             tempsum1 = 0
>             tempsum2 = distribution[2,1]
>             for k = 2:1:length(distribution[1,:])
>                 tempsum1 = tempsum1 + distribution[2,k-1]
>                 tempsum2 = tempsum2 + distribution[2,k]
>                 if Q < tempsum2 && Q > tempsum1
>                     lattice[i].R = distribution[1,k]
>                 end
>             end
>         end
>     end
>     return lattice, R_max, N
> end
> end


And here is how I usually call it:

lattice=Geometry.GeometryFunc(100,0.3,[0.95 0.97 0.99 1.01 1.03 1.05; 0.07 
> 0.10 0.25 0.40 0.10 0.08])


After running the code I can some constructions like:

Geometry.pores{Float64}(0.95, 
[96.62765023884106,36.948114669490664,70.08384291700011])


How it is even possible?

Reply via email to