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
3559138d
Commit
3559138d
authored
Aug 29, 2019
by
MischaD
Browse files
Finished Preperation
parent
91e544e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
lbmweights/exceptions.py
View file @
3559138d
...
...
@@ -7,4 +7,9 @@ class OrderNotImplementedException(Exception):
class
ImpossibleVelocityShellException
(
Exception
):
"""No velocity sets could be constructed. Only positive integer possible
"""
pass
class
ReducibleShellException
(
Exception
):
"""Shell is reducible although it should be irreducible"""
pass
\ No newline at end of file
lbmweights/lattice.py
View file @
3559138d
import
numpy
as
np
import
random
from
lbmweights.utils.mylog
import
logger
from
.exceptions
import
OrderNotImplementedException
,
ImpossibleVelocityShellException
from
.utils.utils
import
analyse_tensor_dimension
,
get_group
from
.exceptions
import
OrderNotImplementedException
,
ImpossibleVelocityShellException
,
ReducibleShellException
from
.utils.utils
import
analyse_tensor_dimension
,
get_group
,
get_subshells
class
Lattice
:
...
...
@@ -19,6 +20,8 @@ class Lattice:
self
.
_tensor_space_dimension
=
0
self
.
_possible_tensors
=
[]
self
.
_velocities
=
0
self
.
_shells
=
0
def
__str__
(
self
):
string
=
"D{} - Order: {} - Shells: {}"
.
format
(
...
...
@@ -60,6 +63,14 @@ class Lattice:
def
tensor_space_dimension
(
self
):
return
np
.
array
([
len
(
x
)
for
x
in
self
.
_possible_tensors
]).
sum
()
@
property
def
shells
(
self
):
self
.
_shells
@
property
def
velocities
(
self
):
self
.
_velocities
@
staticmethod
def
velocities_for_shell
(
dimension
,
shell
):
"""
...
...
@@ -104,12 +115,31 @@ class Lattice:
################################################
velocities_amount
=
1
grand_total_list
=
[]
subshells
=
[]
total_
subshells
=
[]
group
=
get_group
(
self
.
_dimensions
)
# TODO test output
for
shell
in
range
(
len
(
self
.
_shell_list
)):
velocities
=
self
.
velocities_for_shell
(
dimension
=
self
.
_dimensions
,
shell
=
self
.
_shell_list
[
shell
])
if
len
(
velocities
)
==
0
:
raise
ImpossibleVelocityShellException
(
"No velocity sets found for velocity shell {}"
.
format
(
shell
))
raise
ImpossibleVelocityShellException
(
"No velocity sets found for velocity shell {}."
.
format
(
shell
))
subshells
=
get_subshells
(
velocities
,
group
)
total_subshells
.
append
(
len
(
subshells
))
if
len
(
subshells
)
>
1
:
# TODO l.119
raise
ReducibleShellException
(
"Shell {} is reducible"
)
grand_total_list
.
extend
(
subshells
)
velocities_amount
+=
len
(
velocities
)
self
.
_velocities
=
velocities_amount
self
.
_shells
=
len
(
total_subshells
)
+
1
logger
.
info
(
"Velocities: {} Shells: {}"
.
format
(
self
.
_velocities
,
self
.
_shells
))
logger
.
info
(
"Non zero shells: "
)
for
i
,
shell
in
enumerate
(
grand_total_list
):
number_of_velocities
=
len
(
shell
)
type
=
tuple
(
np
.
sort
(
abs
(
shell
[
0
])))
logger
.
info
(
"Shell number {} with c_i^2 = {} and {} velocities of type {}"
.
format
(
i
+
1
,
(
shell
[
0
]
**
2
).
sum
(),
number_of_velocities
,
type
))
random
.
seed
(
self
.
_seed
)
#getlist of subshells
lbmweights/utils/utils.py
View file @
3559138d
...
...
@@ -59,4 +59,22 @@ def get_group(dimension):
return
group
def
contains
(
arr
,
list_of_arr
):
return
any
((
arr
==
x
).
all
()
for
x
in
list_of_arr
)
def
contains_in_sublist
(
arr
,
list_of_lists
):
return
any
(
contains
(
arr
,
list_of_arr
)
for
list_of_arr
in
list_of_lists
)
def
get_subshells
(
shell
,
group
):
subshells
=
[]
for
velocity
in
shell
:
subshell
=
[]
for
i
in
range
(
len
(
group
)):
new
=
np
.
dot
(
group
[
i
],
velocity
)
if
contains
(
new
,
subshell
):
continue
subshell
.
append
(
new
)
if
not
contains_in_sublist
(
velocity
,
subshells
):
subshells
.
append
(
subshell
)
return
subshells
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