Skip to content

Commit

Permalink
Merge pull request #199 from StochSS/model-domain-str
Browse files Browse the repository at this point in the history
Model and Domain str function
  • Loading branch information
seanebum authored Nov 29, 2021
2 parents 671a4f3 + f09f00c commit 7cd32f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
24 changes: 7 additions & 17 deletions spatialpy/Domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'''

import json
import time

import numpy
from scipy.spatial import KDTree
Expand Down Expand Up @@ -86,23 +87,12 @@ def __str__(self):
f"{pad}Domain Size: {self.domain_size}", f"{pad}RHO_0: {self.rho0}", f"{pad}C_0: {self.c0}",
f"{pad}P_0: {self.P0}", f"{pad}Gravity: {self.gravity}", f"{pad}X Limit: {self.xlim}",
f"{pad}Y Limit: {self.ylim}", f"{pad}Z Limit: {self.zlim}"]
domain_strs.extend(["", "Paritcles", ""])
for i, vertex in enumerate(self.vertices):
v_str = f"{pad}{i+1}: {vertex}\n{pad} Volume:{self.vol[i]}, Mass: {self.mass[i]}, "
v_str += f"Type: {self.type[i]}, Viscosity: {self.nu[i]}, Density: {self.rho[i]}, "
v_str += f"Artificial Speed of Sound: {self.c[i]}, Fixed: {self.fixed[i]}"
v_str += f"Type: {self.type[i]}, Viscosity: {self.nu[i]}, Density: {self.rho[i]}, Fixed: {self.fixed[i]}"
domain_strs.append(v_str)
if self.triangles is not None:
domain_strs.extend(["", "Triangles", ""])
for i, triangle in enumerate(self.triangles):
domain_strs.append(f"{pad}{i+1}: {triangle}")
if self.tetrahedrons is not None:
domain_strs.extend(["", "Tetrahedrons", ""])
for i, tetrahedron in enumerate(self.tetrahedrons):
domain_strs.append(f"{pad}{i+1}: {tetrahedron}, Volume: {self.tetrahedron_vol[i]}")

return "\n".join(domain_strs)

print("\n".join(domain_strs))

self._ipython_display_()

return ""

def _ipython_display_(self, use_matplotlib=False):
self.plot_types(width="auto", height="auto", use_matplotlib=use_matplotlib)
Expand Down
15 changes: 12 additions & 3 deletions spatialpy/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,20 @@ def decorate(header):
print_string += decorate("Reactions")
for _, reaction in self.listOfReactions.items():
print_string += f"\n{str(reaction)}"
print(print_string)

if self.domain is not None:
print_string += decorate("Domain")
print_string += f"\n{str(self.domain)}"
print(decorate("Domain"))
print(f"\n{str(self.domain)}")

return print_string
return ""


def _ipython_display_(self, use_matplotlib=False):
if self.domain is None:
print(self)
else:
self.domain.plot_types(width="auto", height="auto", use_matplotlib=use_matplotlib)


def get_expression_utility(self):
Expand Down

0 comments on commit 7cd32f7

Please sign in to comment.