Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mischa Dombrowski
lbmweights
Commits
3135fec2
Commit
3135fec2
authored
Sep 08, 2019
by
MischaD
Browse files
SP Returns
parent
0698e79c
Changes
2
Hide whitespace changes
Inline
Side-by-side
cli.py
View file @
3135fec2
import
click
import
re
from
lbmweights.lattice
import
Lattice
from
lbmweights.utils.utils
import
timer
from
lbmweights.utils.mylog
import
logger
...
...
@@ -8,6 +9,12 @@ from lbmweights.utils.mylog import logger
def
main
():
pass
@
timer
def
benchmark
(
x
=
10
):
for
i
in
range
(
x
):
for
name
,
kwargs
in
Lattice
.
BY_NAME
.
items
():
weights
=
Lattice
(
**
kwargs
).
weights
@
main
.
command
()
@
click
.
option
(
'--dimension'
,
type
=
int
,
default
=
2
,
help
=
'Dimension of the lattice, default 2'
)
...
...
@@ -15,11 +22,12 @@ def main():
@
click
.
option
(
'--shells'
,
type
=
str
,
default
=
"1,2,4"
,
help
=
'String of velocity shell size. Squared length of the shell'
)
@
click
.
option
(
'--seed'
,
type
=
int
,
help
=
'Random number to be used as seed'
)
def
lbmweights
(
dimension
,
order
,
shells
,
seed
):
#shell_list = [int(x) for x in re.findall(u"\d+", shells)]
#Lattice(dimension=dimension, order=order, shell_list=shell_list, seed=seed)
lattice
=
Lattice
.
from_name
()
shell_list
=
[
int
(
x
)
for
x
in
re
.
findall
(
u
"\d+"
,
shells
)]
lattice
=
Lattice
(
dimension
=
dimension
,
order
=
order
,
shell_list
=
shell_list
,
seed
=
seed
)
#benchmark(10)
print
(
lattice
.
velocity_set
())
if
__name__
==
"__main__"
:
main
()
...
...
lbmweights/lattice.py
View file @
3135fec2
...
...
@@ -358,7 +358,7 @@ class Lattice:
if
self
.
_interval
.
contains
(
c_s_sq
)
is
sp
.
EmptySet
:
# Invalid c_s_sq input
return
[]
weights
=
[
sp
.
N
(
x
.
eval
(
c_s_sq
)
)
for
x
in
self
.
_weight_polynomials
]
weights
=
[
x
.
eval
(
c_s_sq
)
for
x
in
self
.
_weight_polynomials
]
weights
=
[
x
if
abs
(
x
)
>=
1e-10
else
0
for
x
in
weights
]
for
i
,
shell
in
enumerate
(
self
.
shells
):
shell
.
set_weight
(
c_s_sq
,
weights
[
i
])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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