Skip to content

Commit 590970f

Browse files
committed
support randles_batmac and some EM materials
1 parent cfa5aeb commit 590970f

File tree

3 files changed

+171
-3
lines changed

3 files changed

+171
-3
lines changed

src/ansys/dyna/core/pre/dynabase.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,22 @@ class Curve:
113113
114114
"""
115115

116-
def __init__(self, sfo=1, x=[], y=[], func=None):
116+
def __init__(self, sfo=1, x=[], y=[], func=None, title=""):
117117
self.sfo = sfo
118118
self.abscissa = x
119119
self.ordinate = y
120120
self.func = func
121+
self.title = title
121122

122123
def create(self, stub=None):
123124
"""Create a curve."""
124125
if stub is None:
125126
stub = DynaBase.get_stub()
126127
if self.func != None:
127-
ret = stub.CreateDefineCurveFunction(DefineCurveFunctionRequest(function=self.func))
128+
ret = stub.CreateDefineCurveFunction(DefineCurveFunctionRequest(function=self.func, title=self.title))
128129
else:
129130
ret = stub.CreateDefineCurve(
130-
DefineCurveRequest(sfo=self.sfo, abscissa=self.abscissa, ordinate=self.ordinate)
131+
DefineCurveRequest(sfo=self.sfo, abscissa=self.abscissa, ordinate=self.ordinate, title=self.title)
131132
)
132133
self.id = ret.id
133134
logging.info(f"Curve {self.id} defined...")
@@ -1529,6 +1530,7 @@ def __init__(self, analysis_type=AnalysisType.IMPLICIT, initial_timestep_size=0)
15291530
self.defined_dynamic = False
15301531
self.defined_eigenvalue = False
15311532
self.defined_solution = False
1533+
self.defined_mass_matrix = False
15321534
self.imflag = analysis_type.value
15331535
self.dt0 = initial_timestep_size
15341536
self.stub = DynaBase.get_stub()
@@ -1640,6 +1642,10 @@ def set_solution(
16401642
self.maxref = stiffness_reformation_limit
16411643
self.abstol = absolute_convergence_tolerance
16421644

1645+
def set_consistent_mass_matrix(self):
1646+
"""Use the consistent mass matrix in implicit dynamics and eigenvalue solutions."""
1647+
self.defined_mass_matrix = True
1648+
16431649
def create(self):
16441650
"""Create an implicit analysis."""
16451651
if self.defined == False:
@@ -1662,6 +1668,8 @@ def create(self):
16621668
nsolver=self.nsolver, ilimit=self.ilimit, maxref=self.maxref, abstol=self.abstol
16631669
)
16641670
)
1671+
if self.defined_mass_matrix:
1672+
self.stub.CreateControlImplicitConsistentMass(ControlImplicitConsistentMassRequest(iflag=1))
16651673

16661674

16671675
class ThermalAnalysisType(Enum):

src/ansys/dyna/core/pre/dynaem.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,3 +732,68 @@ def create(self):
732732
self.id = ret.id
733733
logging.info(f"EM Isopotential Rogo {self.id} Created...")
734734
return self.id
735+
736+
737+
class RandlesCellType(Enum):
738+
USER_DEFINED_EQUIVALENT_CIRCUIT_MODEL = -1
739+
RANDLES_CELL_0_ORDER = 0
740+
RANDLES_CELL_1_ORDER = 1
741+
RANDLES_CELL_2_ORDER = 2
742+
RANDLES_CELL_3_ORDER = 3
743+
744+
745+
class RandlesCell:
746+
"""Define parameters for a Randles Cell."""
747+
748+
def __init__(self, set=None):
749+
self.stub = DynaBase.get_stub()
750+
self.define_batmac = False
751+
752+
def set_batmac_model(
753+
self,
754+
cell_type=RandlesCellType.RANDLES_CELL_1_ORDER,
755+
cell_parts=None,
756+
area=2,
757+
cell_capacity=0,
758+
soc_conversion_factor=0,
759+
charge_init_state=0,
760+
circuit_parameter=None,
761+
constant_temperature=0,
762+
temperature_from_thermal_solver=False,
763+
add_heating_to_thermal_solver=False,
764+
):
765+
"""define the distributed Randles circuit parameters for a Randles cell when using the batmac model."""
766+
self.define_batmac = True
767+
self.rdltype = cell_type.value
768+
self.rdlarea = area
769+
self.psid = cell_parts
770+
self.q = cell_capacity
771+
self.cq = soc_conversion_factor
772+
self.socinit = charge_init_state
773+
self.prm = circuit_parameter
774+
self.temp = constant_temperature
775+
self.frther = temperature_from_thermal_solver
776+
self.r0toth = add_heating_to_thermal_solver
777+
778+
def create(self):
779+
"""Set parameter for Randles Cell."""
780+
if self.define_batmac:
781+
sid = 0
782+
if self.psid is not None:
783+
sid = self.psid.create(self.stub)
784+
ret = self.stub.CreateEMRandlesBatmac(
785+
EMRandlesBatmacRequest(
786+
rdltype=self.rdltype,
787+
rdlarea=self.rdlarea,
788+
psid=sid,
789+
q=self.q,
790+
cq=self.cq,
791+
socinit=self.socinit,
792+
chargedirparam=self.prm,
793+
temp=self.temp,
794+
frther=self.frther,
795+
r0toth=self.r0toth,
796+
)
797+
)
798+
self.id = ret.rdlid
799+
logging.info(f"EM Randles Batmac {self.id} Created...")

src/ansys/dyna/core/pre/dynamaterial.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,24 @@ def set_em_resistive_heating_2d(self, material_type=EMMATTYPE.CONDUCTOR, initial
383383
self.em_material_type = material_type.value
384384
self.em_initial_conductivity = initial_conductivity
385385

386+
def set_em_randles_batmac(
387+
self, positive_current_collector_conductivity=0, negative_current_collector_conductivity=0
388+
):
389+
"""Define two conductivities per EM node for special applications (Randles Batmac).
390+
391+
Parameters
392+
----------
393+
positive_current_collector_conductivity : float
394+
conductivities of the positive current collector materials
395+
negative_current_collector_conductivity : float
396+
conductivities of the negative current collector materials
397+
398+
"""
399+
self.em_mat_type = 6
400+
self.em_material_type = 5
401+
self.sigp = positive_current_collector_conductivity
402+
self.sign = negative_current_collector_conductivity
403+
386404
def set_thermal_isotropic(
387405
self, density=0, generation_rate=0, generation_rate_multiplier=0, specific_heat=0, conductivity=0
388406
):
@@ -436,6 +454,10 @@ def create(self, stub, matid):
436454
stub.CreateEMMat004(
437455
EMMat004Request(mid=matid, mtype=self.em_material_type, sigma=self.em_initial_conductivity)
438456
)
457+
elif self.em_mat_type == 6:
458+
stub.CreateEMMat006(
459+
EMMat006Request(mid=matid, mtype=self.em_material_type, sigp=self.sigp, sign=self.sign)
460+
)
439461
if self.em:
440462
if self.em_eos is not None:
441463
eosid = self.em_eos.create(stub)
@@ -477,6 +499,29 @@ def create(self, stub):
477499
logging.info(f"Material {self.name} Created...")
478500

479501

502+
class MatPlasticKinematic:
503+
"""Define material of modelling isotropic and kinematic hardening plasticity."""
504+
505+
def __init__(
506+
self, mass_density=0, young_modulus=0, poisson_ratio=0.3, yield_stress=0, tangent_modulus=0, hardening=0
507+
):
508+
self.ro = mass_density
509+
self.e = young_modulus
510+
self.pr = poisson_ratio
511+
self.sigy = yield_stress
512+
self.etan = tangent_modulus
513+
self.beta = hardening
514+
515+
def create(self, stub):
516+
"""Create plastic kinematic material."""
517+
ret = stub.CreateMatPlasticKinematic(
518+
MatPlasticKinematicRequest(ro=self.ro, e=self.e, pr=self.pr, sigy=self.sigy, etan=self.etan, beta=self.beta)
519+
)
520+
self.material_id = ret.mid
521+
self.name = "Plastic Kinematic"
522+
logging.info(f"Material {self.name} Created...")
523+
524+
480525
class MatElasticPlasticThermal(MatAdditional):
481526
"""Defines temperature-dependent material coefficients."""
482527

@@ -555,6 +600,32 @@ def create(self, stub):
555600
logging.info(f"Material {self.name} Created...")
556601

557602

603+
class MatCrushableFoam:
604+
"""Define material of modelling crushable foam."""
605+
606+
def __init__(
607+
self, mass_density=0, young_modulus=0, poisson_ratio=0.3, yield_stress_curve=None, tensile_stress_cutoff=0
608+
):
609+
self.ro = mass_density
610+
self.e = young_modulus
611+
self.pr = poisson_ratio
612+
self.lcid = yield_stress_curve
613+
self.tsl = tensile_stress_cutoff
614+
615+
def create(self, stub):
616+
"""Create crushable foam material."""
617+
if self.lcid is not None:
618+
cid = self.lcid.create(stub)
619+
else:
620+
cid = 0
621+
ret = stub.CreateMatCrushableFoam(
622+
MatCrushableFoamRequest(ro=self.ro, e=self.e, pr=self.pr, lcid=cid, tsl=self.tsl)
623+
)
624+
self.material_id = ret.mid
625+
self.name = "Crushable Foam"
626+
logging.info(f"Material {self.name} Created...")
627+
628+
558629
class MatThermalIsotropic:
559630
"""Defines isotropic thermal properties."""
560631

@@ -581,6 +652,30 @@ def create(self, stub):
581652
logging.info(f"Material {self.name} Created...")
582653

583654

655+
class MatThermalOrthotropic:
656+
"""Defines orthotropic thermal properties."""
657+
658+
def __init__(self, specific_heat=0, conductivity_x=0, conductivity_y=0, conductivity_z=0):
659+
self.hc = specific_heat
660+
self.k1 = conductivity_x
661+
self.k2 = conductivity_y
662+
self.k3 = conductivity_z
663+
664+
def create(self, stub):
665+
"""Create orthotropic thermal material."""
666+
ret = stub.CreateMatThermalOrthotropic(
667+
MatThermalOrthotropicRequest(
668+
hc=self.hc,
669+
k1=self.k1,
670+
k2=self.k2,
671+
k3=self.k3,
672+
)
673+
)
674+
self.material_id = ret.mid
675+
self.name = "Orthotropic thermal"
676+
logging.info(f"Material {self.name} Created...")
677+
678+
584679
class MatRigidDiscrete:
585680
"""Defines a rigid material for shells or solids.
586681

0 commit comments

Comments
 (0)