Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support define_function_tabulated,boundary_convection_set,em_randles_… #306

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.2",
"ansys-api-dyna==0.3.3",
]

[project.optional-dependencies]
Expand Down
64 changes: 63 additions & 1 deletion src/ansys/dyna/core/pre/dynabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,27 @@ class Function:

def __init__(self, Function=None):
self.function = Function
self.tabulated = False

def set_tabulated(self, heading="", function="", x=[], y=[]):
self.tabulated = True
self.heading = heading
self.function_name = function
self.x = x
self.y = y

def create(self, stub):
"""Create function."""
if self.tabulated:
ret = stub.CreateDefineFunctionTabulated(
DefineFunctionTabulatedRequest(
heading=self.heading, function=self.function_name, abscissa=self.x, ordinate=self.y
)
)
ret = stub.CreateDefineFunction(DefineFunctionRequest(function=self.function))
self.id = ret.id
logging.info(f"Function {self.id} defined...")

return self.id


Expand Down Expand Up @@ -2229,6 +2244,7 @@ def __init__(self):
self.spclist = []
self.imposedmotionlist = []
self.templist = []
self.convectionlist = []

def create_spc(
self,
Expand Down Expand Up @@ -2310,6 +2326,39 @@ def create_temperature(
param = [nodeset, curve, scalefactor]
self.templist.append(param)

def create_convection(
self,
segmentset=None,
convection_heat_transfer_coefficient=None,
convection_heat_transfer_coefficient_multiplier=0.0,
environment_temperature=None,
environment_temperature_multiplier=0.0,
):
"""Apply a convection boundary condition on SEGMENT_SET for a thermal analysis.

Parameters
----------
segmentset : SegmentSet.
Segment set.
convection_heat_transfer_coefficient : Curve
Convection heat transfer coefficient.
convection_heat_transfer_coefficient_multiplier : float
Curve multiplier for convection heat transfer coefficient.
environment_temperature : Curve
Environment temperature.
environment_temperature_multiplier : float
Curve multiplier for environment temperature.

"""
param = [
segmentset,
convection_heat_transfer_coefficient,
convection_heat_transfer_coefficient_multiplier,
environment_temperature,
environment_temperature_multiplier,
]
self.convectionlist.append(param)

def create(self):
"""Create a boundary condition."""
for obj in self.imposedmotionlist:
Expand Down Expand Up @@ -2404,7 +2453,7 @@ def create(self):
nid = nodeset.create(self.stub)
option = "SET"
if curve is not None:
cid = curve.id
cid = curve.create(self.stub)
else:
cid = 0
self.stub.CreateBdyTemp(
Expand All @@ -2416,6 +2465,19 @@ def create(self):
)
)
logging.info("Boundary Temperature Created...")
for obj in self.convectionlist:
ss, hlc, hmult, tlc, tmult = obj[0], obj[1], obj[2], obj[3], obj[4]
ssid, hlcid, tlcid = 0, 0, 0
if ss is not None:
ssid = ss.create(self.stub)
if hlc is not None:
hlcid = hlc.create(self.stub)
if tlc is not None:
tlcid = tlc.create(self.stub)
self.stub.CreateBdyConvection(
BdyConvectionRequest(ssid=ssid, pserod=0, hlcid=hlcid, hmult=hmult, tlcid=tlcid, tmult=tmult, loc=0)
)
logging.info("Boundary Convection Created...")


class InitialCondition:
Expand Down
20 changes: 20 additions & 0 deletions src/ansys/dyna/core/pre/dynaem.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ def __init__(self, set=None):
self.stub = DynaBase.get_stub()
self.define_batmac = False
self.define_randles_short = False
self.define_extra_heat_source = False

def set_batmac_model(
self,
Expand Down Expand Up @@ -804,6 +805,19 @@ def set_randles_short(self, resistances_func=None):
self.define_randles_short = True
self.randles_short_function = resistances_func

def set_extra_heat_source(self, heat_source_func=None):
"""Add an extra heat source term to the Randles circuit nodes in order to account for thermal runaway
situations.

Parameters
----------
heat_source_func : Function
Define the local heat source function of local parameters for the local Randles circuit.

"""
self.define_extra_heat_source = True
self.heat_source_func = heat_source_func

def create(self):
"""Set parameter for Randles Cell."""
if self.define_batmac:
Expand Down Expand Up @@ -845,3 +859,9 @@ def create(self):
fid = self.randles_short_function.create(self.stub)
ret = self.stub.CreateEMRandlesShort(EMRandlesShortRequest(function=fid))
logging.info(f"EM Randles Short Created...")
if self.define_extra_heat_source:
fid = 0
if self.heat_source_func is not None:
fid = self.heat_source_func.create(self.stub)
ret = self.stub.CreateEMRandlesExothermicReaction(EMRandlesExothermicReactionRequest(function=fid))
logging.info(f"EM Randles Exothermic Reaction Created...")