tFix ambiguity errors with floats - Granular.jl - Julia package for granular dy… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 5abf1529e8f726546dfdf049211b438e3071f3d9 | |
parent 9bc01e9c4afd4765c0e358041265cfbd6c14f8c2 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 4 Dec 2018 08:29:42 +0100 | |
Fix ambiguity errors with floats | |
Diffstat: | |
M examples/image.jl | 40 ++++++++++++++++-------------… | |
1 file changed, 20 insertions(+), 20 deletions(-) | |
--- | |
diff --git a/examples/image.jl b/examples/image.jl | |
t@@ -40,7 +40,7 @@ const Ly = ny*dy | |
const youngs_modulus = 2e7 | |
const tensile_strength = 0e3 | |
-const h = .5 | |
+const h = 0.5 | |
sim = Granular.createSimulation(id="image") | |
t@@ -51,12 +51,12 @@ for iy=1:size(img_bw, 1) | |
x = ix*dx - dx | |
if forcing == "sandpile" | |
- x += Lx/6. | |
+ x += Lx/6.0 | |
end | |
y = Ly - (iy*dy - dy) | |
- r = .5*dx*((1. - Float64(img_bw[iy, ix]))) | |
+ r = 0.5*dx*((1.0 - Float64(img_bw[iy, ix]))) | |
- if r > .1*dx | |
+ if r > 0.1*dx | |
Granular.addGrainCylindrical!(sim, [x + dx, y - dy], r, h, | |
tensile_strength=tensile_strength, | |
youngs_modulus=youngs_modulus, | |
t@@ -66,38 +66,38 @@ for iy=1:size(img_bw, 1) | |
end | |
# set ocean forcing | |
-sim.ocean = Granular.createRegularOceanGrid([nx, ny, 1], [Lx, Ly, 1.], | |
+sim.ocean = Granular.createRegularOceanGrid([nx, ny, 1], [Lx, Ly, 1.0], | |
name="image_ocean") | |
if forcing == "gyres" | |
epsilon = 0.25 # amplitude of periodic oscillations | |
- t = 0. | |
- a = epsilon*sin(2.*pi*t) | |
- b = 1. - 2.*epsilon*sin(2.*pi*t) | |
+ t = 0.0 | |
+ a = epsilon*sin(2.0*pi*t) | |
+ b = 1.0 - 2.0*epsilon*sin(2.0*pi*t) | |
for i=1:size(sim.ocean.u, 1) | |
for j=1:size(sim.ocean.u, 2) | |
- x = sim.ocean.xq[i, j]/(Lx*.5) # x in [0;2] | |
+ x = sim.ocean.xq[i, j]/(Lx*0.5) # x in [0;2] | |
y = sim.ocean.yq[i, j]/Ly # y in [0;1] | |
- f = a*x^2. + b*x | |
- df_dx = 2.*a*x + b | |
+ f = a*x^2.0 + b*x | |
+ df_dx = 2.0*a*x + b | |
- sim.ocean.u[i, j, 1, 1] = -pi/10.*sin(pi*f)*cos(pi*y) * 4e1 | |
- sim.ocean.v[i, j, 1, 1] = pi/10.*cos(pi*f)*sin(pi*y)*df_dx * 4e1 | |
+ sim.ocean.u[i, j, 1, 1] = -pi/10.0*sin(pi*f)*cos(pi*y) * 4e1 | |
+ sim.ocean.v[i, j, 1, 1] = pi/10.0*cos(pi*f)*sin(pi*y)*df_dx * 4e1 | |
end | |
end | |
elseif forcing == "down" || forcing == "sandpile" | |
srand(1) | |
- sim.ocean.u[:, :, 1, 1] = (rand(nx+1, ny+1) - .5)*.1 | |
- sim.ocean.v[:, :, 1, 1] = -Ly/5. | |
+ sim.ocean.u[:, :, 1, 1] = (rand(nx+1, ny+1) - 0.5)*0.1 | |
+ sim.ocean.v[:, :, 1, 1] = -Ly/5.0 | |
elseif forcing == "convergent" | |
srand(1) | |
- sim.ocean.u[:, :, 1, 1] = (rand(nx+1, ny+1) - .5)*.1 | |
+ sim.ocean.u[:, :, 1, 1] = (rand(nx+1, ny+1) - 0.5)*0.1 | |
for j=1:size(sim.ocean.u, 2) | |
- sim.ocean.v[:, j, 1, 1] = -(j/ny - .5)*10. | |
+ sim.ocean.v[:, j, 1, 1] = -(j/ny - 0.5)*10.0 | |
end | |
else | |
t@@ -108,7 +108,7 @@ end | |
r = dx/4. | |
## N-S wall segments | |
-for y in range(r, stop=Ly-r, length=Int(round((Ly - 2.*r)/(r*2)))) | |
+for y in range(r, stop=Ly-r, length=Int(round((Ly - 2.0*r)/(r*2)))) | |
Granular.addGrainCylindrical!(sim, [r, y], r, h, fixed=true, | |
youngs_modulus=youngs_modulus, | |
verbose=false) | |
t@@ -118,7 +118,7 @@ for y in range(r, stop=Ly-r, length=Int(round((Ly - 2.*r)/… | |
end | |
## E-W wall segments | |
-for x in range(3.*r, stop=Lx-3.*r, length=Int(round((Lx - 6.*r)/(r*2)))) | |
+for x in range(3.0*r, stop=Lx-3.0*r, length=Int(round((Lx - 6.0*r)/(r*2)))) | |
Granular.addGrainCylindrical!(sim, [x, r], r, h, fixed=true, | |
youngs_modulus=youngs_modulus, | |
verbose=false) | |
t@@ -131,7 +131,7 @@ end | |
# Finalize setup and start simulation | |
Granular.setTimeStep!(sim, verbose=verbose) | |
-Granular.setTotalTime!(sim, 5.) | |
+Granular.setTotalTime!(sim, 5.0) | |
Granular.setOutputFileInterval!(sim, .1) | |
Granular.removeSimulationFiles(sim) |