Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/zzqbranch'
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhuiuy committed Aug 11, 2023
2 parents 9fcf587 + c5cbe63 commit e6ebc18
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [

dependencies = [
"ansys-dpf-core>=0.7.2",
"ansys-api-dyna==0.3.0",
"ansys-api-dyna==0.3.1",
]

[project.optional-dependencies]
Expand Down
53 changes: 53 additions & 0 deletions src/ansys/dyna/core/pre/dynabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,32 @@ def create(self, stub):
return self.id


class Table2D:
"""Define a table,a curve ID is specified for each value defined in the table."""

def __init__(self, title=""):
self.title = title
self.valuecurvelist = []

def append(self, value=0, curve=None):
self.valuecurvelist.append((value, curve))

def create(self, stub=None):
"""Create Table2D."""
if stub is None:
stub = DynaBase.get_stub()
vls = []
cvs = []
for obj in self.valuecurvelist:
vls.append(obj[0])
cid = obj[1].create(stub)
cvs.append(cid)
ret = stub.CreateDefineTable2D(DefineTable2DRequest(title=self.title, values=vls, cids=cvs))
self.id = ret.id
logging.info(f"Table2D {self.id} defined...")
return self.id


class Point:
"""Defines a point."""

Expand Down Expand Up @@ -886,6 +912,33 @@ def create(self, stub):
return self.id


class NodeSetBox(BaseSet):
"""include the nodes inside boxes.
Parameters
----------
boxes : list
A list of BOX.
"""

def __init__(self, boxes=[]):
self.boxes = boxes
self.type = "NODESETBOX"

def create(self, stub):
"""Create a node set."""
if len(self.boxes) <= 0:
return 0
boxids = []
for box in self.boxes:
boxid = box.create(stub)
boxids.append(boxid)
ret = stub.CreateNodeSet(NodeSetRequest(option="GENERAL", sid=0, genoption="BOX", entities=boxids))
self.id = ret.id
self.type = "NODESETBOX"
return self.id


class PartSet(BaseSet):
"""Defines a set of parts with optional attributes."""

Expand Down
21 changes: 17 additions & 4 deletions src/ansys/dyna/core/pre/dynaem.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,15 @@ def create(self):
logging.info("EM Contact Created...")


class EMRandlesLayer(Enum):
DEFAULT = 0
CURRENT_COLLECTOR_POSITIVE = 1
POSITIVE_ELECTRODE = 2
SEPARATOR = 3
NEGATIVE_ELECTRODE = 4
CURRENT_COLLECTOR_NEGATIVE = 5


class Isopotential:
"""Defines an isopotential.
Expand All @@ -682,25 +691,29 @@ class Isopotential:

isopotlist = []

def __init__(self, set=None):
def __init__(self, set=None, layer=EMRandlesLayer.DEFAULT):
self.stub = DynaBase.get_stub()
self.set = set
self.id = 0
self.rdltype = layer.value

def create(self):
"""Create an isopotential."""
isoinfo = [self.set.type, self.set.nodes]
if self.set.type == "NODESETBOX":
isoinfo = [self.set.type, self.set.boxes]
else:
isoinfo = [self.set.type, self.set.nodes]
if isoinfo in Isopotential.isopotlist:
pass
id, settype = 0, 1
if self.set is not None:
id = self.set.create(self.stub)
type = self.set.type
if type == "NODESET":
if type == "NODESET" or type == "NODESETBOX":
settype = 2
elif type == "SEGMENTSET":
settype = 1
ret = self.stub.CreateEMIsopotential(EMIsopotentialRequest(settype=settype, setid=id))
ret = self.stub.CreateEMIsopotential(EMIsopotentialRequest(settype=settype, setid=id, rdltype=self.rdltype))
self.id = ret.id
logging.info(f"EM Isopotential {self.id} Created...")
return self.id
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/dyna/core/pre/dynamaterial.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,13 @@ def create(self, stub):
logging.info(f"Material {self.name} Created...")


class MatCrushableFoam:
class MatCrushableFoam(MatAdditional):
"""Define material of modelling crushable foam."""

def __init__(
self, mass_density=0, young_modulus=0, poisson_ratio=0.3, yield_stress_curve=None, tensile_stress_cutoff=0
):
MatAdditional.__init__(self)
self.ro = mass_density
self.e = young_modulus
self.pr = poisson_ratio
Expand All @@ -623,6 +624,7 @@ def create(self, stub):
)
self.material_id = ret.mid
self.name = "Crushable Foam"
MatAdditional.create(self, stub, self.material_id)
logging.info(f"Material {self.name} Created...")


Expand Down

0 comments on commit e6ebc18

Please sign in to comment.