Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
s.zitz
JuThinFilm
Commits
738222c9
Commit
738222c9
authored
Sep 14, 2020
by
s.zitz
Browse files
Tests fixed
😄
parent
bddb2212
Pipeline
#22868
failed with stage
in 5 minutes and 33 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
test/calcmoments.jl
View file @
738222c9
@testset
"Calculating macroscopic moments"
begin
@testset
"No velocity height only"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
mom
=
default_moments
(
Float64
,
5
,
5
)
macroscopicmoments!
(
mom
,
dists
)
...
...
@@ -9,7 +9,7 @@
@test
all
(
mom
.
velocity
.
y
.==
0.0
)
end
@testset
"With velocity"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
dists
.
fout
[
:
,
:
,
2
]
.=
0.2
dists
.
fout
[
:
,
:
,
3
]
.=
0.3
...
...
@@ -21,7 +21,7 @@
end
@testset
"With velocity and all 9 directions"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
dists
.
fout
[
:
,
:
,
2
]
.=
0.2
dists
.
fout
[
:
,
:
,
3
]
.=
0.3
...
...
@@ -38,7 +38,7 @@
@test
all
(
mom
.
velocity
.
y
.==
(
0.3
-
0.5
+
0.6
+
0.7
-
0.8
-
0.9
)
/
(
0.1
+
0.2
+
0.3
+
0.4
+
0.5
+
0.6
+
0.7
+
0.8
+
0.9
))
end
@testset
"With velocity and all 9 directions on the GPU"
begin
dists
=
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
dists
.
fout
[
:
,
:
,
2
]
.=
0.2
dists
.
fout
[
:
,
:
,
3
]
.=
0.3
...
...
@@ -55,7 +55,7 @@
@test
all
(
mom
.
velocity
.
y
.==
(
0.3
-
0.5
+
0.6
+
0.7
-
0.8
-
0.9
)
/
(
0.1
+
0.2
+
0.3
+
0.4
+
0.5
+
0.6
+
0.7
+
0.8
+
0.9
))
end
@testset
"Force correction no velocity"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
mom
=
default_moments
(
Float64
,
5
,
5
)
f
=
default_force
(
Float64
,
5
,
5
)
...
...
@@ -66,7 +66,7 @@
@test
all
(
mom
.
velocity
.
y
.==
(
0.5
/
2
)
/
0.1
)
end
@testset
"Force correction with velocity"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
dists
.
fout
[
:
,
:
,
2
]
.=
0.2
dists
.
fout
[
:
,
:
,
3
]
.=
0.3
...
...
@@ -88,7 +88,7 @@
@test
all
(
mom
.
velocity
.
y
.==
(
vely
+
f
.
y
[
1
,
1
]
/
2
)
/
sum1
)
end
@testset
"Force correction with velocity CuArrays"
begin
dists
=
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
dists
.
fout
[
:
,
:
,
2
]
.=
0.2
dists
.
fout
[
:
,
:
,
3
]
.=
0.3
...
...
@@ -112,7 +112,7 @@
end
@testset
"Performance moments"
begin
@testset
"Moments without forcing"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
dists
.
fout
[
:
,
:
,
2
]
.=
0.2
dists
.
fout
[
:
,
:
,
3
]
.=
0.3
...
...
@@ -130,7 +130,7 @@ end
@test
btime
≤
t0
+
t0
/
100
*
10
end
@testset
"Moments with forcing"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
))
dists
.
fout
[
:
,
:
,
1
]
.=
0.1
dists
.
fout
[
:
,
:
,
2
]
.=
0.2
dists
.
fout
[
:
,
:
,
3
]
.=
0.3
...
...
test/equilibria.jl
View file @
738222c9
@testset
"
e
quilibria"
begin
@testset
"
E
quilibria"
begin
@testset
"CPU"
begin
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
lat
=
JuThinFilm
.
lattice
{
Float64
}()
par
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
)
@test
isa
(
lat
,
JuThinFilm
.
lattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@testset
"No gravity no velocity equilibrium!()"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_moments
(
T
,
5
,
5
)
lat
=
lattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
)
@test
isa
(
lat
,
lattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@test
isa
(
mom
,
moments
)
@test
isa
(
mom
,
JuThinFilm
.
moments
)
@test
all
(
dists
.
feq
.==
0.0
)
equilibrium!
(
dists
,
mom
,
lat
,
par
)
@test
isa
(
dists
.
feq
,
Array
{
Float64
,
3
})
...
...
@@ -18,14 +18,10 @@
end
end
@testset
"No gravity no velocity equilibrium!() many arguments"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_moments
(
T
,
5
,
5
)
lat
=
lattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
)
@test
isa
(
lat
,
lattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@test
isa
(
mom
,
moments
)
@test
isa
(
mom
,
JuThinFilm
.
moments
)
dists
.
feq
.=
0.0
@test
all
(
dists
.
feq
.==
0.0
)
equilibrium!
(
dists
.
feq
,
mom
.
height
,
mom
.
velocity
.
x
,
mom
.
velocity
.
y
,
mom
.
pressure
,
lat
.
ci
,
lat
.
wi
,
par
)
@test
isa
(
dists
.
feq
,
Array
{
Float64
,
3
})
...
...
@@ -35,21 +31,18 @@
end
end
@testset
"Gravity no velocity equilibrium!()"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_moments
(
T
,
5
,
5
)
lat
=
lattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
,
gravity
=
0.1
)
@test
isa
(
lat
,
lattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@test
isa
(
mom
,
moments
)
par1
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
,
gravity
=
0.1
)
@test
isa
(
mom
,
JuThinFilm
.
moments
)
dists
.
feq
.=
0.0
@test
all
(
dists
.
feq
.==
0.0
)
equilibrium!
(
dists
,
mom
,
lat
,
par
)
equilibrium!
(
dists
,
mom
,
lat
,
par
1
)
@test
isa
(
dists
.
feq
,
Array
{
Float64
,
3
})
@test
all
(
dists
.
feq
[
:
,
:
,
1
]
.==
1.0
-
1
/
12
)
solution
=
zeros
(
5
,
5
,
9
)
for
i
in
2
:
9
solution
[
:
,
:
,
i
]
.=
lat
.
wi
[
i
]
.*
mom
.
height
.*
(
1.5
.*
par
.
gravity
.*
mom
.
height
.+
solution
[
:
,
:
,
i
]
.=
lat
.
wi
[
i
]
.*
mom
.
height
.*
(
1.5
.*
par
1
.
gravity
.*
mom
.
height
.+
3
.*
(
lat
.
ci
[
i
,
1
]
.*
mom
.
velocity
.
x
.+
lat
.
ci
[
i
,
2
]
.*
mom
.
velocity
.
y
)
.+
4.5
.*
(
lat
.
ci
[
i
,
1
]
.*
mom
.
velocity
.
x
.+
lat
.
ci
[
i
,
2
]
.*
mom
.
velocity
.
y
)
.^
2
.-
1.5
.*
(
mom
.
velocity
.
x
.^
2
.+
mom
.
velocity
.
y
.^
2
))
...
...
@@ -58,14 +51,10 @@
end
@testset
"No gravity with velocity in x equilibrium!()"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_moments
(
T
,
5
,
5
)
lat
=
lattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
)
@test
isa
(
lat
,
lattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@test
isa
(
mom
,
moments
)
@test
isa
(
mom
,
JuThinFilm
.
moments
)
dists
.
feq
.=
0.0
@test
all
(
dists
.
feq
.==
0.0
)
mom
.
velocity
.
x
=
fill
(
0.1
,
(
5
,
5
))
equilibrium!
(
dists
,
mom
,
lat
,
par
)
...
...
@@ -82,14 +71,10 @@
end
@testset
"No gravity with velocity in x & y equilibrium!()"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_moments
(
T
,
5
,
5
)
lat
=
lattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
)
@test
isa
(
lat
,
lattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@test
isa
(
mom
,
moments
)
@test
isa
(
mom
,
JuThinFilm
.
moments
)
dists
.
feq
.=
0.0
@test
all
(
dists
.
feq
.==
0.0
)
mom
.
velocity
.
x
=
fill
(
0.1
,
(
5
,
5
))
mom
.
velocity
.
y
=
fill
(
0.2
,
(
5
,
5
))
...
...
@@ -107,19 +92,17 @@
end
@testset
"Gravity and velocity in x & y equilibrium!()"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_moments
(
T
,
5
,
5
)
lat
=
lattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
,
gravity
=
0.1
)
par1
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
,
gravity
=
0.1
)
mom
.
velocity
.
x
.=
0.1
mom
.
velocity
.
y
.=
0.2
equilibrium!
(
dists
,
mom
,
lat
,
par
)
equilibrium!
(
dists
,
mom
,
lat
,
par
1
)
@test
isa
(
dists
.
feq
,
Array
{
Float64
,
3
})
@test
all
(
dists
.
feq
[
:
,
:
,
1
]
.==
mom
.
height
.-
5
/
6
.*
par
.
gravity
.*
mom
.
height
.^
2
.-
2
/
3
*
(
mom
.
velocity
.
x
.^
2
.+
mom
.
velocity
.
y
.^
2
))
@test
all
(
dists
.
feq
[
:
,
:
,
1
]
.==
mom
.
height
.-
5
/
6
.*
par
1
.
gravity
.*
mom
.
height
.^
2
.-
2
/
3
*
(
mom
.
velocity
.
x
.^
2
.+
mom
.
velocity
.
y
.^
2
))
solution
=
zeros
(
5
,
5
,
9
)
for
i
in
2
:
9
solution
[
:
,
:
,
i
]
.=
lat
.
wi
[
i
]
.*
mom
.
height
.*
(
1.5
.*
par
.
gravity
.*
mom
.
height
.+
solution
[
:
,
:
,
i
]
.=
lat
.
wi
[
i
]
.*
mom
.
height
.*
(
1.5
.*
par
1
.
gravity
.*
mom
.
height
.+
3
.*
(
lat
.
ci
[
i
,
1
]
.*
mom
.
velocity
.
x
.+
lat
.
ci
[
i
,
2
]
.*
mom
.
velocity
.
y
)
.+
4.5
.*
(
lat
.
ci
[
i
,
1
]
.*
mom
.
velocity
.
x
.+
lat
.
ci
[
i
,
2
]
.*
mom
.
velocity
.
y
)
.^
2
.-
1.5
.*
(
mom
.
velocity
.
x
.^
2
.+
mom
.
velocity
.
y
.^
2
))
...
...
@@ -128,15 +111,17 @@
end
end
@testset
"GPU"
begin
dists
=
JuThinFilm
.
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
lat
=
JuThinFilm
.
culattice
{
Float64
}()
par
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
)
par1
=
JuThinFilm
.
params
{
Float64
}(
lx
=
5
,
ly
=
5
,
gravity
=
0.1
)
@test
isa
(
lat
,
JuThinFilm
.
culattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@testset
"No gravity no velocity equilibrium!()"
begin
dists
=
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
default_cumoments
(
T
,
5
,
5
)
lat
=
culattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
)
@test
isa
(
lat
,
culattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@test
isa
(
mom
,
cumoments
)
@test
isa
(
mom
,
JuThinFilm
.
cumoments
)
dists
.
feq
.=
0.0
@test
all
(
dists
.
feq
.==
0.0
)
equilibrium!
(
dists
.
feq
,
mom
.
height
,
mom
.
velocity
.
x
,
mom
.
velocity
.
y
,
mom
.
pressure
,
lat
.
ci
,
lat
.
wi
,
par
)
@test
isa
(
dists
.
feq
,
CuArray
{
Float64
,
3
})
...
...
@@ -147,33 +132,26 @@
end
@testset
"Gravity no velocity equilibrium!()"
begin
dists
=
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_cumoments
(
T
,
5
,
5
)
lat
=
culattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
,
gravity
=
0.1
)
@test
isa
(
lat
,
culattice
)
@test
isa
(
par
,
JuThinFilm
.
params
)
@test
isa
(
mom
,
cumoments
)
mom
=
default_cumoments
(
T
,
5
,
5
)
dists
.
feq
.=
0.0
@test
all
(
dists
.
feq
.==
0.0
)
equilibrium!
(
dists
.
feq
,
mom
.
height
,
mom
.
velocity
.
x
,
mom
.
velocity
.
y
,
mom
.
pressure
,
lat
.
ci
,
lat
.
wi
,
par
)
equilibrium!
(
dists
.
feq
,
mom
.
height
,
mom
.
velocity
.
x
,
mom
.
velocity
.
y
,
mom
.
pressure
,
lat
.
ci
,
lat
.
wi
,
par
1
)
@test
isa
(
dists
.
feq
,
CuArray
{
Float64
,
3
})
feq
=
zeros
(
5
,
5
,
9
)
feq
.=
Array
(
dists
.
feq
)
@test
all
(
feq
[
:
,
:
,
1
]
.==
1.0
-
1
/
12
)
for
i
in
2
:
5
@test
all
(
feq
[
:
,
:
,
i
]
.
≈
1
/
9
*
3
/
2
*
par
.
gravity
.*
Array
(
mom
.
height
)
.^
2
)
@test
all
(
feq
[
:
,
:
,
i
]
.
≈
1
/
9
*
3
/
2
*
par
1
.
gravity
.*
Array
(
mom
.
height
)
.^
2
)
end
for
i
in
6
:
9
@test
all
(
feq
[
:
,
:
,
i
]
.
≈
1
/
36
*
3
/
2
*
par
.
gravity
.*
Array
(
mom
.
height
)
.^
2
)
@test
all
(
feq
[
:
,
:
,
i
]
.
≈
1
/
36
*
3
/
2
*
par
1
.
gravity
.*
Array
(
mom
.
height
)
.^
2
)
end
end
@testset
"No gravity with velocity in x equilibrium!()"
begin
dists
=
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_cumoments
(
T
,
5
,
5
)
lat
=
culattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
)
dists
.
feq
.=
0.0
@test
all
(
dists
.
feq
.==
0.0
)
mom
.
velocity
.
x
.=
0.1
equilibrium!
(
dists
.
feq
,
mom
.
height
,
mom
.
velocity
.
x
,
mom
.
velocity
.
y
,
mom
.
pressure
,
lat
.
ci
,
lat
.
wi
,
par
)
...
...
@@ -190,11 +168,9 @@
end
@testset
"No gravity with velocity in x equilibrium!()"
begin
dists
=
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_cumoments
(
T
,
5
,
5
)
lat
=
culattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
)
dists
.
feq
.=
0.0
@test
all
(
dists
.
feq
.==
0.0
)
mom
.
velocity
.
x
.=
0.1
mom
.
velocity
.
y
.=
0.2
...
...
@@ -211,22 +187,21 @@
end
end
@testset
"No gravity with velocity in x equilibrium!()"
begin
dists
=
cudistributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
@testset
"Gravity with velocity in x equilibrium!()"
begin
T
=
Float64
mom
=
JuThinFilm
.
default_cumoments
(
T
,
5
,
5
)
lat
=
culattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
,
gravity
=
0.
2
)
par2
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
,
gravity
=
0.2
)
dists
.
feq
.
=
0.
0
@test
all
(
dists
.
feq
.==
0.0
)
mom
.
velocity
.
x
.=
0.1
mom
.
velocity
.
y
.=
0.2
equilibrium!
(
dists
.
feq
,
mom
.
height
,
mom
.
velocity
.
x
,
mom
.
velocity
.
y
,
mom
.
pressure
,
lat
.
ci
,
lat
.
wi
,
par
)
equilibrium!
(
dists
.
feq
,
mom
.
height
,
mom
.
velocity
.
x
,
mom
.
velocity
.
y
,
mom
.
pressure
,
lat
.
ci
,
lat
.
wi
,
par
2
)
feq
=
zeros
(
5
,
5
,
9
)
feq
.=
Array
(
dists
.
feq
)
@test
all
(
feq
[
:
,
:
,
1
]
.==
Array
(
mom
.
height
)
.-
5
/
6
.*
par
.
gravity
.*
Array
(
mom
.
height
)
.^
2
.-
2
/
3
.*
(
Array
(
mom
.
velocity
.
x
)
.^
2
.+
Array
(
mom
.
velocity
.
y
)
.^
2
))
@test
all
(
feq
[
:
,
:
,
1
]
.==
Array
(
mom
.
height
)
.-
5
/
6
.*
par
2
.
gravity
.*
Array
(
mom
.
height
)
.^
2
.-
2
/
3
.*
(
Array
(
mom
.
velocity
.
x
)
.^
2
.+
Array
(
mom
.
velocity
.
y
)
.^
2
))
solution
=
zeros
(
5
,
5
,
9
)
for
i
in
2
:
9
solution
[
:
,
:
,
i
]
.=
lat
.
wi
[
i
]
.*
Array
(
mom
.
height
)
.*
(
1.5
.*
par
.
gravity
.*
Array
(
mom
.
height
)
.+
solution
[
:
,
:
,
i
]
.=
lat
.
wi
[
i
]
.*
Array
(
mom
.
height
)
.*
(
1.5
.*
par
2
.
gravity
.*
Array
(
mom
.
height
)
.+
3
.*
(
lat
.
ci
[
i
,
1
]
.*
Array
(
mom
.
velocity
.
x
)
.+
lat
.
ci
[
i
,
2
]
.*
Array
(
mom
.
velocity
.
y
))
.+
4.5
.*
(
lat
.
ci
[
i
,
1
]
.*
Array
(
mom
.
velocity
.
x
)
.+
lat
.
ci
[
i
,
2
]
.*
Array
(
mom
.
velocity
.
y
))
.^
2
.-
1.5
.*
(
Array
(
mom
.
velocity
.
x
)
.^
2
.+
Array
(
mom
.
velocity
.
y
)
.^
2
))
...
...
@@ -234,7 +209,6 @@
end
end
end
@testset
"Velocity square moments"
begin
mom
=
default_moments
(
Float64
,
5
,
5
)
res
=
JuThinFilm
.
velsquare
(
mom
)
...
...
@@ -249,10 +223,10 @@
end
@testset
"Performance equilibrium"
begin
dists
=
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
JuThinFilm
.
params
(
lx
=
5
,
ly
=
5
))
T
=
Float64
mom
=
JuThinFilm
.
default_moments
(
T
,
5
,
5
)
lat
=
lattice
{
T
}()
mom
=
default_moments
(
T
,
5
,
5
)
lat
=
JuThinFilm
.
lattice
{
T
}()
par
=
JuThinFilm
.
params
{
T
}(
lx
=
5
,
ly
=
5
)
mom
.
velocity
.
x
.=
0.1
mom
.
velocity
.
y
.=
0.2
...
...
test/forcing.jl
View file @
738222c9
...
...
@@ -233,4 +233,56 @@
@test
all
(
fsum
.
y
.==
-
f1
.
y
.-
f2
.
y
.-
f3
.
y
.-
f4
.
y
)
end
end
end
@testset
"Performance of forces"
begin
lx
=
5
ly
=
5
f
=
default_force
(
Float64
,
lx
,
ly
)
mom
=
default_moments
(
Float64
,
lx
,
ly
)
@testset
"Slippage"
begin
col
=
JuThinFilm
.
collisionparams
{
Float64
}()
mom
.
velocity
.
x
.=
0.1
mom
.
velocity
.
y
.=
0.2
benchres
=
@benchmark
slippage!
(
$
f
.
x
,
$
f
.
y
,
$
mom
.
height
,
$
mom
.
velocity
.
x
,
$
mom
.
velocity
.
y
,
$
col
)
benchtime
=
median
(
benchres
)
.
time
/
10
^
6
t0
=
0.001
@test
benchtime
≤
t0
end
@testset
"Thermal fluctuations"
begin
col
=
JuThinFilm
.
collisionparams
{
Float64
}(
kᵦT
=
11
/
6
,
μ
=
2.0
)
benchres
=
@benchmark
thermalflutuations!
(
$
f
,
$
mom
,
$
col
)
benchtime
=
median
(
benchres
)
.
time
/
10
^
6
t0
=
0.001
@test
benchtime
≤
t0
end
@testset
"Pressure gradient"
begin
pressure
=
reshape
(
collect
(
1.0
:
25.0
),
5
,
5
)
padpressure
=
padarray
(
pressure
,
Pad
(
:
circular
,
1
,
1
))
benchres
=
@benchmark
h∇p!
(
$
f
.
x
,
$
f
.
y
,
$
mom
.
height
,
$
padpressure
)
benchtime
=
median
(
benchres
)
.
time
/
10
^
6
t0
=
0.001
@test
benchtime
≤
t0
end
@testset
"Inclined plane"
begin
t
=
1
mag
=
0.001
benchres
=
@benchmark
inclinedplane!
(
$
f
.
x
,
$
f
.
y
,
$
mom
.
height
,
$
t
,
$
mag
,
$
true
,
$
true
)
benchtime
=
median
(
benchres
)
.
time
/
10
^
6
t0
=
0.0005
@test
benchtime
≤
t0
end
@testset
"Summation of forces"
begin
f2
=
default_force
(
Float64
,
5
,
5
)
f3
=
default_force
(
Float64
,
5
,
5
)
f4
=
default_force
(
Float64
,
5
,
5
)
f2
.
x
.=
0.2
;
f3
.
x
.=
0.3
;
f4
.
x
.=
0.4
f2
.
y
.=
-
0.2
;
f3
.
y
.=
-
0.3
;
f4
.
y
.=
-
0.4
benchres
=
@benchmark
sumforces!
(
$
f
.
x
,
$
f
.
y
,
$
f2
.
x
,
$
f2
.
y
,
$
f3
.
x
,
$
f3
.
y
,
$
f4
.
x
,
$
f4
.
y
)
benchtime
=
median
(
benchres
)
.
time
/
10
^
6
t0
=
0.001
@test
benchtime
≤
t0
end
end
\ No newline at end of file
test/pressure.jl
View file @
738222c9
@testset
"Pressure functionality"
begin
tolerances
=
Dict
(
Float16
=>
1e-3
,
Float32
=>
1e-6
,
Float64
=>
1e-9
)
# Testing the power function
@testset
"power_broad"
begin
n
=
4
...
...
@@ -18,9 +17,8 @@
@test
isa
(
resFlt64
,
Float64
)
@test
resFlt
==
16.0
@test
isa
(
resArr
,
Array
{
Float64
,
1
})
for
i
in
1
:
5
@test
resArr
[
i
]
==
16.0
end
@test
all
(
resArr
.==
16.0
)
end
# Testing the disjoing pressure Π
...
...
@@ -42,9 +40,7 @@
@test
isa
(
resFlt64
,
Float64
)
@test
resFlt
==
0.0
@test
isa
(
resArr
,
Array
{
Float64
,
1
})
for
i
in
1
:
5
@test
resArr
[
i
]
==
0.0
end
@test
all
(
resArr
.==
0.0
)
# With contact angle
γ
=
0.01
...
...
@@ -60,10 +56,7 @@
@test
isa
(
resFlt64
,
Float64
)
@test
resFlt64
==
γ
*
8
/
3
*
(
1
/
512.0
-
1
/
8.0
)
@test
isa
(
resArr
,
Array
{
Float64
,
1
})
for
i
in
1
:
5
@test
resArr
[
i
]
==
γ
*
8
/
3
*
(
1
/
512.0
-
1
/
8.0
)
end
@test
all
(
resArr
.==
γ
*
8
/
3
*
(
1
/
512.0
-
1
/
8.0
))
end
# Test the laplacian
...
...
test/runtests.jl
View file @
738222c9
...
...
@@ -8,7 +8,7 @@ using Test, CUDA, Random, Statistics, LinearAlgebra, Images, BenchmarkTools
include
(
"equilibria.jl"
)
# This is fixed and works for v 0.0.2
include
(
"calcmoments.jl"
)
# This is fixed and works for v 0.0.2
include
(
"collisions.jl"
)
# This is fixed and works for v 0.0.2
#
include("forcing.jl")
include
(
"forcing.jl"
)
# include("runsimulation.jl")
# include("measurements.jl")
end
test/structs.jl
View file @
738222c9
...
...
@@ -22,7 +22,7 @@
@testset
"lattice"
begin
# Default constructor
lat
=
lattice
{
Float64
}()
lat
=
JuThinFilm
.
lattice
{
Float64
}()
@test
lat
.
ci
[
:
,
1
]
==
[
0
,
1
,
0
,
-
1
,
0
,
1
,
-
1
,
-
1
,
1
]
@test
lat
.
ci
[
:
,
2
]
==
[
0
,
0
,
1
,
0
,
-
1
,
1
,
1
,
-
1
,
-
1
]
@test
isa
(
lat
.
ci
,
Array
{
Int
,
2
})
...
...
@@ -32,13 +32,13 @@
@test
size
(
lat
.
ci
,
1
)
==
9
@test
size
(
lat
.
ci
,
2
)
==
2
lat2
=
lattice
{
Float32
}()
lat2
=
JuThinFilm
.
lattice
{
Float32
}()
@test
isa
(
lat2
.
wi
,
Array
{
Float32
,
1
})
end
@testset
"culattice"
begin
# Default constructor
lat
=
culattice
{
Float32
}()
lat
=
JuThinFilm
.
culattice
{
Float32
}()
@test
lat
.
ci
[
:
,
1
]
==
[
0
,
1
,
0
,
-
1
,
0
,
1
,
-
1
,
-
1
,
1
]
@test
lat
.
ci
[
:
,
2
]
==
[
0
,
0
,
1
,
0
,
-
1
,
1
,
1
,
-
1
,
-
1
]
@test
isa
(
lat
.
ci
,
CuArray
{
Int
,
2
})
...
...
@@ -52,7 +52,7 @@
@testset
"pressurestats"
begin
# Default constructor
teststats
=
pressurestats
{
Float64
}()
teststats
=
JuThinFilm
.
pressurestats
{
Float64
}()
@test
teststats
.
γ
==
0.01
@test
isa
(
teststats
.
γ
,
Float64
)
@test
teststats
.
n
==
9
...
...
@@ -68,14 +68,14 @@
@testset
"velocity"
begin
# Default constructor
parameters
=
JuThinFilm
.
params
{
Float64
}()
testvel
=
velocity
{
Float64
}(
para
=
parameters
)
testvel
=
JuThinFilm
.
velocity
{
Float64
}(
para
=
parameters
)
@test
parameters
.
lx
==
size
(
testvel
.
x
,
1
)
@test
parameters
.
ly
==
size
(
testvel
.
x
,
2
)
@test
isa
(
testvel
.
x
,
Array
{
Float64
,
2
})
@test
isa
(
testvel
.
y
,
Array
{
Float64
,
2
})
@test
all
(
testvel
.
x
.==
0.0
)
@test
all
(
testvel
.
y
.==
0.0
)
# Mutable structs have fields that can be
alter
ed
# Mutable structs have fields that can be
chang
ed
testvel
.
x
[
256
,
256
]
=
1.0
@test
testvel
.
x
[
256
,
256
]
==
1.0
end
...
...
@@ -99,7 +99,7 @@
# Pretty much the same as a velocity, however easier to differentiate if they are called differently
# Default constructor
parameters
=
JuThinFilm
.
params
{
Float64
}()
forcing
=
force
{
Float64
}(
para
=
parameters
)
forcing
=
JuThinFilm
.
force
{
Float64
}(
para
=
parameters
)
@test
isa
(
forcing
.
x
,
Array
{
Float64
,
2
})
@test
isa
(
forcing
.
y
,
Array
{
Float64
,
2
})
@test
all
(
forcing
.
x
.==
0.0
)
...
...
@@ -127,7 +127,7 @@
@testset
"moments"
begin
parameters
=
JuThinFilm
.
params
{
Float64
}()
testvel
=
velocity
{
Float64
}(
para
=
parameters
)
testvel
=
JuThinFilm
.
velocity
{
Float64
}(
para
=
parameters
)
mom
=
JuThinFilm
.
moments
{
Float64
}(
para
=
parameters
,
velocity
=
testvel
)
@test
size
(
mom
.
height
,
1
)
==
parameters
.
lx
@test
size
(
mom
.
height
,
2
)
==
parameters
.
ly
...
...
@@ -172,7 +172,7 @@
end
@testset
"collisionparams"
begin
col
=
collisionparams
{
Float64
}()
col
=
JuThinFilm
.
collisionparams
{
Float64
}()
@test
col
.
τ
==
1.0
@test
col
.
ω
==
1.0
@test
col
.
cₛ
==
sqrt
(
1
/
3
)
...
...
@@ -184,7 +184,7 @@
@testset
"distributions"
begin
para
=
JuThinFilm
.
params
{
Float64
}(
lx
=
10
,
ly
=
20
)
dists
=
distributions
{
Float64
}(
para
=
para
)
dists
=
JuThinFilm
.
distributions
{
Float64
}(
para
=
para
)
@test
isa
(
dists
.
feq
,
Array
{
Float64
,
3
})
@test
isa
(
dists
.
ftemp
,
Array
{
Float64
,
3
})
@test
isa
(
dists
.
fout
,
Array
{
Float64
,
3
})
...
...
@@ -200,9 +200,9 @@
T
=
Float32
n
,
m
=
4
,
4
mom
=
default_moments
(
T
,
n
,
m
)
@test
isa
(
mom
,
moments
)
@test
isa
(
mom
,
JuThinFilm
.
moments
)
@test
isa
(
mom
.
height
,
Array
{
T
,
2
})
@test
isa
(
mom
.
velocity
,
velocity
)
@test
isa
(
mom
.
velocity
,
JuThinFilm
.
velocity
)
@test
isa
(
mom
.
velocity
.
x
,
Array
{
T
,
2
})
@test
isa
(
mom
.
velocity
.
y
,
Array
{
T
,
2
})
@test
isa
(
mom
.
pressure
,
Array
{
T
,
2
})
...
...
@@ -215,9 +215,9 @@
T
=
Float32
n
,
m
=
4
,
4
mom
=
default_cumoments
(
T
,
n
,
m
)
@test
isa
(
mom
,
cumoments
)
@test
isa
(
mom
,
JuThinFilm
.
cumoments
)
@test
isa
(
mom
.
height
,
CuArray
{
T
,
2
})
@test
isa
(
mom
.
velocity
,
cuvelocity
)
@test
isa
(
mom
.
velocity
,
JuThinFilm
.
cuvelocity
)
@test
isa
(
mom
.
velocity
.
x
,
CuArray
{
T
,
2
})
@test
isa
(
mom
.
velocity
.
y
,
CuArray
{
T
,
2
})
@test
isa
(
mom
.
pressure
,
CuArray
{
T
,
2
})
...
...
@@ -229,7 +229,7 @@
T
=
Float32
n
,
m
=
4
,
4
F
=
default_force
(
T
,
n
,
m
)
@test
isa
(
F
,
force
)
@test
isa
(
F
,
JuThinFilm
.
force
)
@test
isa
(
F
.
x
,
Array
{
T
,
2
})
@test
isa
(
F
.
y
,
Array
{
T
,
2
})
@test
size
(
F
.
x
)
==
(
4
,
4
)
...
...
@@ -241,7 +241,7 @@
T
=
Float32
n
,
m
=
4
,
4
F
=
default_cuforce
(
T
,
n
,
m
)
@test
isa
(
F
,
cuforce
)
@test
isa
(
F
,
JuThinFilm
.
cuforce
)
@test
isa
(
F
.
x
,
CuArray
{
T
,
2
})
@test
isa
(
F
.
y
,
CuArray
{
T
,
2
})
@test
size
(
F
.
x
)
==
(
4
,
4
)
...
...
@@ -253,7 +253,7 @@
T
=
Float32
n
,
m
=
4
,
4
vel
=
default_velocity
(
T
,
n
,
m
)
@test
isa
(
vel
,
velocity
)
@test
isa
(
vel
,
JuThinFilm
.
velocity
)
@test
isa
(
vel
.
x
,
Array
{
T
,
2
})
@test
isa
(
vel
.
y
,
Array
{
T
,
2
})
@test
size
(
vel
.
x
)
==
(
4
,
4
)
...
...
@@ -265,7 +265,7 @@
T
=
Float32
n
,
m
=
4
,
4
vel
=
default_cuvelocity
(
T
,
n
,
m
)
@test
isa
(
vel
,
cuvelocity
)
@test
isa
(
vel
,
JuThinFilm
.
cuvelocity
)
@test
isa
(
vel
.
x
,
CuArray
{
T
,
2
})
@test
isa
(
vel
.
y
,
CuArray
{
T
,
2
})
@test
size
(
vel
.
x
)
==
(
4
,
4
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment