Skip to content

Commit 7ff1119

Browse files
committed
Merge remote-tracking branch 'origin/zzqbranch'
2 parents c1b69e0 + a15bd57 commit 7ff1119

22 files changed

+222
-49
lines changed

docker/solver/README.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,20 @@ Prerequisites
2727
* Download the latest Linux release artifacts for the Linux Docker container:
2828
`mppdyna_docker_centos7.zip <https://github.com/ansys/pydyna/releases/tag/v0.3.1/mppdyna_docker_centos7.zip>`_.
2929

30-
* Move these ZIP files to a a local directory ``local_image_build_dir``.
30+
* Move these ZIP files to the directory of pydyna/docker/solver and unzip the mppdyna_docker_centos7.zip file.
3131

32+
The files in this folder should look similar to this:
33+
34+
.. code:: bash
35+
36+
>>> Dockerfile README.rst do_build docker-compose.yml docker_dir mpi mppdyna_docker_centos7.zip ssh IMAGE ID CREATED SIZE
3237
3338
Build the Docker image
3439
----------------------
3540

3641
Once all prerequisites are met, perform these steps to build the Docker image:
3742

38-
#. In your terminal, go to the ``local_image_build_dir`` directory.
43+
#. In your terminal, go to the ``pydyna/docker/solver`` directory.
3944
#. Run this Docker command:
4045

4146
.. code:: bash

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ classifiers = [
2727

2828
dependencies = [
2929
"ansys-dpf-core>=0.7.2",
30-
"ansys-api-dyna==0.2.0",
30+
"ansys-api-dyna==0.3.0",
3131
]
3232

3333
[project.optional-dependencies]

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

tests/testfiles/standard/base.k

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $# usrstr usrfrc nsbcs interm xpene ssthk ecdt tiedprj
1313
$# sfric dfric edc vfc th th_sf pen_sf ptscl
1414

1515
$# ignore frceng skiprwg outseg spotstp spotdel spothin dir_tie
16-
1
16+
1
1717
$# isym nserod rwgaps rwgdth rwksf icov swradf ithoff
1818

1919
$# shledg pstiff ithcnt tdcnof ftall unused shltrw igactc

tests/testfiles/standard/em/railgun.k

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $# usrstr usrfrc nsbcs interm xpene ssthk ecdt tiedprj
77
$# sfric dfric edc vfc th th_sf pen_sf ptscl
88

99
$# ignore frceng skiprwg outseg spotstp spotdel spothin dir_tie
10-
1
10+
1
1111
$# isym nserod rwgaps rwgdth rwksf icov swradf ithoff
1212

1313
$# shledg pstiff ithcnt tdcnof ftall unused shltrw igactc

tests/testfiles/standard/em/resistive_heating.k

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ $# a1 o1
9393
100.0 400000.0
9494
*SET_NODE_LIST
9595
$# sid da1 da2 da3 da4 solver its -
96-
1 MECH 1
96+
1 MECH
9797
$# nid1 nid2 nid3 nid4 nid5 nid6 nid7 nid8
9898
4507 4508 0 0 0 0 0 0
9999
*ELEMENT_SOLID

tests/testfiles/standard/em/resistive_heating_2d.k

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ $# a1 o1
5656
10.0 10.0
5757
*SET_NODE_LIST
5858
$# sid da1 da2 da3 da4 solver its -
59-
1 MECH 1
59+
1 MECH
6060
$# nid1 nid2 nid3 nid4 nid5 nid6 nid7 nid8
6161
521 517 513 509 525 0 0 0
6262
*SET_NODE_LIST
6363
$# sid da1 da2 da3 da4 solver its -
64-
2 MECH 1
64+
2 MECH
6565
$# nid1 nid2 nid3 nid4 nid5 nid6 nid7 nid8
6666
585 605 625 564 565 0 0 0
6767
*SET_PART_LIST

tests/testfiles/standard/em/resistive_heating_2d_isopots.k

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ $# a1 o1
5656
10.0 10.0
5757
*SET_NODE_LIST
5858
$# sid da1 da2 da3 da4 solver its -
59-
1 MECH 1
59+
1 MECH
6060
$# nid1 nid2 nid3 nid4 nid5 nid6 nid7 nid8
6161
521 517 513 509 525 0 0 0
6262
*SET_NODE_LIST
6363
$# sid da1 da2 da3 da4 solver its -
64-
2 MECH 1
64+
2 MECH
6565
$# nid1 nid2 nid3 nid4 nid5 nid6 nid7 nid8
6666
642 652 661 670 643 0 0 0
6767
*SET_NODE_LIST
6868
$# sid da1 da2 da3 da4 solver its -
69-
3 MECH 1
69+
3 MECH
7070
$# nid1 nid2 nid3 nid4 nid5 nid6 nid7 nid8
7171
549 548 577 597 617 0 0 0
7272
*SET_NODE_LIST
7373
$# sid da1 da2 da3 da4 solver its -
74-
4 MECH 1
74+
4 MECH
7575
$# nid1 nid2 nid3 nid4 nid5 nid6 nid7 nid8
7676
653 644 626 627 662 0 0 0
7777
*SET_PART_LIST

0 commit comments

Comments
 (0)