Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4fb7f1e
Fixed defaults for Domain.add_point. closes #299.
BryanRumsey Jul 26, 2022
0007cae
Added a class for cominatory geometry.
BryanRumsey Jul 27, 2022
1052431
Added numpy.bool_ to geometry.inside return type check.
BryanRumsey Jul 27, 2022
de83919
Added the new geometry to the import sturcture.
BryanRumsey Jul 27, 2022
a2bc83f
Updated cylinder demo to use new geometry for middle type.
BryanRumsey Jul 27, 2022
e5668f7
Added a lattice error class.
BryanRumsey Jul 27, 2022
19aa6ab
Added the lattice module.
BryanRumsey Jul 27, 2022
abcd36e
Added a base class for lattices.
BryanRumsey Jul 27, 2022
0f4a5fe
Added missing kwargs arg to apply.
BryanRumsey Jul 27, 2022
c7e9b0d
Added the cartesian lattice.
BryanRumsey Jul 27, 2022
6c45d5f
Added checks to apply function to ensure proper args are passed. Add…
BryanRumsey Jul 27, 2022
628eb00
Bug fixes.
BryanRumsey Jul 27, 2022
9187fc7
Added the cartesian and spherical lattices to the import structure.
BryanRumsey Jul 27, 2022
40383de
Added 2D support to the cartesian lattice.
BryanRumsey Jul 29, 2022
78086d8
Added validation checks to combinatory geometry.
BryanRumsey Jul 29, 2022
bd1fa75
Merge branch 'geometry-combinations' of https://github.com/StochSS/Sp…
BryanRumsey Jul 29, 2022
165f82c
Added cylindrical lattice.
BryanRumsey Jul 29, 2022
81a1014
Added the cylindrical lattice to the import structure.
BryanRumsey Jul 29, 2022
3db8f5e
Bug fixes.
BryanRumsey Jul 29, 2022
0ffc721
Merge branch 'geometry-combinations' of https://github.com/StochSS/Sp…
BryanRumsey Jul 29, 2022
6cf9c8a
Fixed the get bounding box function.
BryanRumsey Jul 29, 2022
19668bc
Added function to update the domain limits after all particles have b…
BryanRumsey Jul 29, 2022
afa0ba2
Updated the get bounding box function.
BryanRumsey Jul 29, 2022
b20e2a2
Added the XMLMesh lattice.
BryanRumsey Jul 29, 2022
762fc7e
Added the XMLMesh to the import stucture.
BryanRumsey Jul 29, 2022
bb5b312
More bug fixes.
BryanRumsey Jul 29, 2022
6ed15d8
Merge branch 'geometry-combinations' of https://github.com/StochSS/Sp…
BryanRumsey Jul 29, 2022
8053a63
Added the mesh IO lattice.
BryanRumsey Jul 29, 2022
1fc7323
Added the mesh IO lattice to the import structure.
BryanRumsey Jul 29, 2022
a49596d
Added stochss lattice class.
BryanRumsey Jul 31, 2022
5654ef2
Added the stochss lattice class to the import structure.
BryanRumsey Jul 31, 2022
82c0f73
Yet more bug fixes.
BryanRumsey Aug 1, 2022
99a0c5a
Bug fixes.
BryanRumsey Aug 2, 2022
a802794
Fixed circular imports.
BryanRumsey Aug 5, 2022
c6fb9a7
Added support for meshio objects to the meshio lattice.
BryanRumsey Aug 8, 2022
e9e3cda
Fixed issue with center transformation being applied too early.
BryanRumsey Aug 9, 2022
d8b0a30
Merge branch 'develop' of https://github.com/StochSS/SpatialPy into g…
BryanRumsey Aug 12, 2022
1f34493
Merge branch 'geometry-combinations' of https://github.com/StochSS/Sp…
BryanRumsey Aug 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14,657 changes: 43 additions & 14,614 deletions examples/3D_Cylinder_Demo.ipynb

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions spatialpy/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .datafunction import DataFunction
from .domain import Domain
from .geometry import (
CombinatoryGeometry,
Geometry,
GeometryAll,
GeometryExterior,
Expand All @@ -37,6 +38,14 @@
UniformInitialCondition,
ScatterInitialCondition
)
from .lattice import (
CartesianLattice,
SphericalLattice,
CylindricalLattice,
XMLMeshLattice,
MeshIOLattice,
StochSSLattice
)
from .model import Model, export_StochSS
from .parameter import Parameter
from .reaction import Reaction
Expand Down
22 changes: 6 additions & 16 deletions spatialpy/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def compile_prep(self):
self.listOfTypeIDs = list(self.typeNdxMapping.values())
self._get_type_name_mapping()

def add_point(self, point, vol=0, mass=0, type_id=1, nu=0, fixed=False, rho=None, c=0):
def add_point(self, point, vol=1, mass=1, type_id=1, nu=0, fixed=False, rho=None, c=10):
"""
Add a single point particle to the domain space.

Expand Down Expand Up @@ -492,22 +492,12 @@ def get_bounding_box(self):
Get the bounding box of the entire domain.

:returns: Limits of the bounding box.
:rtype: float | float | float | float | float | float
:rtype: tuple(float(2), float(2), float(2))
"""
for i in range(self.vertices.shape[0]):
if xhi < self.vertices[i, 0]:
xhi = self.vertices[i, 0]
if xlo > self.vertices[i, 0]:
xlo = self.vertices[i, 0]
if yhi < self.vertices[i, 1]:
yhi = self.vertices[i, 1]
if ylo > self.vertices[i, 1]:
ylo = self.vertices[i, 1]
if zhi < self.vertices[i, 2]:
zhi = self.vertices[i, 2]
if zlo > self.vertices[i, 2]:
zlo = self.vertices[i, 2]
return xhi, xlo, yhi, ylo, zhi, zlo
xlim = (min(self.vertices[:, 0]), max(self.vertices[:, 0]))
ylim = (min(self.vertices[:, 1]), max(self.vertices[:, 1]))
zlim = (min(self.vertices[:, 2]), max(self.vertices[:, 2]))
return xlim, ylim, zlim

def get_vol(self):
"""
Expand Down
59 changes: 59 additions & 0 deletions spatialpy/core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,67 @@

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import numpy

from spatialpy.core.spatialpyerror import GeometryError

class CombinatoryGeometry:
"""
Combinatory Geometry class uses one or more Geometry class for inclusion or exclusion of
multiple geometric shapes.

:param formula: Boolean logic formula to be evaluated. Example use: "(geo1 or geo2) and not geo3".
:type formula: str

:param geo_namespace: Namespace used when evaluating the formula. Example use:
{'geo1': Geometry1(), 'geo2': Geometry2(), 'geo3': Geometry3()} where 'geo1',
'geo2', and 'geo3' are found in the formula.
:type geo_namespace: dict
"""
def __init__(self, formula, geo_namespace):
self.formula = formula
self.geo_namespace = geo_namespace

self.validate()

def inside(self, point, on_boundary):
"""
:param point: X, Y, Z coodinates for the particle.
:type point: float[3]

:param on_boundary: Indicates whether a particle is on the edge of the domain.
:type on_boundary: bool

:returns: True if the particle satisfies boolean condition for all geometies, else False.
:rtype: bool

:raises GeometryError: If any geometries inside method does not return a bool.
"""
namespace = {}
for name, geometry in self.geo_namespace.items():
val = geometry.inside(point, on_boundary)
if not isinstance(val, (bool, numpy.bool_)):
errmsg = f"{name} is not a valid Geometry obj. Reason given: inside() method must return a bool"
raise GeometryError(errmsg)
namespace[name] = val
return eval(self.formula, {}, namespace)

def validate(self):
"""
Validate the combinatory geometry object.
"""
keys = list(self.geo_namespace.keys())
for name in keys:
if name not in self.formula:
raise GeometryError("geo_namespace entries must be in the formula.")
keys.extend(['and', 'or', 'not', '(', ')'])
formula = self.formula
for item in keys:
formula = formula.replace(item, "")
if formula.strip() != "":
errmsg = f"formula may only contain boolean operators or geometries in geo_namespace not {formula.split(' ')}"
raise GeometryError(errmsg)

class Geometry:
"""
Geometry class provides a method for tagging parts of the spatial domain as separate parts.
Expand Down
Loading