Skip to content

Commit 0739c14

Browse files
committed
Merge remote-tracking branch 'origin/zhanqun/dyna-prev4' into main
2 parents 1f36e5d + 2e1e24e commit 0739c14

28 files changed

+45810
-4249
lines changed
36.2 KB
Loading

examples/EM/em_railgun.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232
if len(sys.argv) > 1:
3333
hostname = sys.argv[1]
3434

35-
em_solution = DynaSolution(hostname)
35+
solution = DynaSolution(hostname)
3636
fns = []
3737
path = examples.em_railgun + os.sep
3838
fns.append(path + "em_railgun.k")
39-
em_solution.open_files(fns)
40-
em_solution.set_termination(termination_time=3e-4)
41-
em_solution.create_database_binary(dt=5e-6)
39+
solution.open_files(fns)
40+
solution.set_termination(termination_time=3e-4)
41+
solution.create_database_binary(dt=5e-6)
4242

4343
railgun = DynaEM()
44-
em_solution.add(railgun)
44+
solution.add(railgun)
4545

4646
railgun.analysis.set_timestep(timestep=5e-6)
4747
railgun.analysis.set_solver_bem(solver=BEMSOLVER.PCG)
@@ -90,5 +90,8 @@
9090
railgun.contacts.add(contact)
9191

9292
railgun.set_rogowsky_coil_to_output_current(SegmentSet(cur))
93+
railgun.create_em_database_globalenergy(outlv=1)
9394

94-
em_solution.save_file()
95+
railgun.create_em_output(mats=2, matf=2, sols=2, solf=2)
96+
97+
solution.save_file()
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
"""
2+
Resistive heating
3+
=================
4+
5+
This example introduces the user to the minimum number of keywords required to turn on the EM resistive heating solver. \n
6+
LS-DYNA version : ls-dyna_smp_d_R13.1_138-g8429c8a10f_winx64_ifort190.exe
7+
"""
8+
9+
import os
10+
import sys
11+
12+
from ansys.dyna.core.pre.dynasolution import DynaSolution
13+
from ansys.dyna.core.pre.dynaem import (
14+
DynaEM,
15+
NodeSet,
16+
Curve,
17+
SolidPart,
18+
SolidFormulation,
19+
FEMSOLVER,
20+
ThermalAnalysis,
21+
ThermalAnalysisType,
22+
EMType
23+
)
24+
from ansys.dyna.core.pre.dynamaterial import MatElastic,MatThermalIsotropic,EMMATTYPE,EMEOSTabulated1
25+
from em_set_data import *
26+
from ansys.dyna.core.pre import examples
27+
# sphinx_gallery_thumbnail_path = '_static/pre/em/em_resistive_heating.png'
28+
29+
hostname = "localhost"
30+
if len(sys.argv) > 1:
31+
hostname = sys.argv[1]
32+
33+
solution = DynaSolution(hostname)
34+
fns = []
35+
path = examples.em_resistive_heating + os.sep
36+
fns.append(path + "em_resistive_heating.k")
37+
solution.open_files(fns)
38+
solution.set_termination(termination_time=20)
39+
solution.create_database_binary(dt=0.1)
40+
41+
emobj = DynaEM()
42+
solution.add(emobj)
43+
44+
emobj.set_timestep(timestep_size_for_mass_scaled=0.01,max_timestep=Curve(x=[0,9.9999997474e-5],y=[0.01,0.01]))
45+
46+
emobj.analysis.set_timestep(timestep=0.01)
47+
emobj.analysis.set_em_solver(type=EMType.RESISTIVE_HEATING)
48+
emobj.analysis.set_solver_fem(solver=FEMSOLVER.DIRECT_SOLVER, relative_tol=1e-3)
49+
50+
tanalysis = ThermalAnalysis()
51+
tanalysis.set_timestep(initial_timestep=0.05)
52+
tanalysis.set_solver(analysis_type=ThermalAnalysisType.TRANSIENT)
53+
emobj.add(tanalysis)
54+
55+
matelastic1 = MatElastic(mass_density=8000, young_modulus=1e11, poisson_ratio=0.33)
56+
matelastic2 = MatElastic(mass_density=7000, young_modulus=1e11, poisson_ratio=0.33)
57+
matelastic1.set_electromagnetic_property(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=6e7)
58+
matelastic2.set_electromagnetic_property(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=4e6,eos=EMEOSTabulated1(Curve(x=[0, 25, 50, 100], y=[4e6, 4e6, 4e5, 4e5])))
59+
60+
matthermaliso1 = MatThermalIsotropic(density=8000,specific_heat=400, conductivity=400)
61+
matthermaliso2 = MatThermalIsotropic(density=7000,specific_heat=450, conductivity=40)
62+
63+
part2 = SolidPart(2)
64+
part2.set_material(matelastic1,matthermaliso1)
65+
part2.set_element_formulation(SolidFormulation.CONSTANT_STRESS_SOLID_ELEMENT)
66+
emobj.parts.add(part2)
67+
68+
part3 = SolidPart(3)
69+
part3.set_material(matelastic1,matthermaliso1)
70+
part3.set_element_formulation(SolidFormulation.CONSTANT_STRESS_SOLID_ELEMENT)
71+
emobj.parts.add(part3)
72+
73+
part1 = SolidPart(1)
74+
part1.set_material(matelastic2,matthermaliso2)
75+
part1.set_element_formulation(SolidFormulation.CONSTANT_STRESS_SOLID_ELEMENT)
76+
emobj.parts.add(part1)
77+
78+
emobj.boundaryconditions.create_temperature(NodeSet(resistive_heating_tmp), scalefactor=50)
79+
emobj.set_init_temperature(temp=25)
80+
81+
emobj.create_em_output(mats=2, matf=2, sols=2, solf=2)
82+
83+
solution.save_file()

examples/EM/em_set_data.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
resistive_heating_tmp = [4507,4508,4505,4506,4547,4548,4545,4546,4558,4557,4563,4568,4578,4577,4587,4588,
2+
4597,4598,4608,4607,4617,4618,4627,4628,4647,4648,4657,4658,4677,4678,4687,4688,
3+
4707,4708,4738,4737,4748,4747,4758,4757,4768,4767,4808,4818,4823,4828,4858,4863,
4+
4868,4873,4898,4908,4913,4918,4948,4953,4958,4963,4988,4998,5003,5008,5038,5043,
5+
5048,5053,5088,5087,5098,5097,5103,5108,5118,5117,5123,5128,5138,5137,6367,6366,
6+
6365,6364,6407,6406,6405,6404,6417,6416,6422,6427,6437,6436,6447,6446,6457,6456,
7+
6467,6466,6477,6476,6487,6486,6507,6506,6517,6516,6537,6536,6547,6546,6567,6566,
8+
6597,6596,6607,6606,6617,6616,6627,6626,6667,6677,6682,6687,6717,6722,6727,6732,
9+
6757,6767,6772,6777,6807,6812,6817,6822,6847,6857,6862,6867,6897,6902,6907,6912,
10+
6947,6946,6957,6956,6962,6967,6977,6976,6982,6987,6997,6996,7832,7831,7834,7833,
11+
7836,7835,7838,7837,7840,7839,7842,7841,7844,7843,7846,7845,7848,7847,7850,7849,
12+
7852,7851,7854,7853,7856,7855,7858,7857,7860,7859,7862,7861,7864,7863,7866,7865,
13+
7868,7867,7870,7869,7872,7871,7874,7873,7876,7875,7878,7877,7880,7879,7882,7881,
14+
7884,7883,7886,7885,7888,7887,7890,7889,7892,7891,7894,7893,7896,7895,7898,7897,
15+
7900,7899,7902,7901,7904,7903,7906,7905,7908,7907,7910,7909,7912,7911,7914,7913,
16+
7916,7915,7918,7917,7920,7919,7922,7921,7924,7923,7926,7925,7928,7927,7930,7929,
17+
7932,7931,7934,7933,7936,7935,7938,7937,7940,7939,7942,7941,7944,7943,7946,7945,
18+
7948,7947,7950,7949,7952,7951,7954,7953,7956,7955,7958,7957,7960,7959,7962,7961,
19+
7964,7963,7966,7965,7968,7967,7970,7969,7972,7971,7974,7973,7976,7975,7978,7977,
20+
7980,7979,7982,7981,7984,7983,7986,7985,7988,7987,7990,7989,7992,7991,7994,7993,
21+
7996,7995,7998,7997,8000,7999,8002,8001,8004,8003,8006,8005,8008,8007,8010,8009,
22+
8012,8011,8014,8013,8016,8015,8018,8017,8020,8019,12152,12151,12154,12153,12156,12155,
23+
12158,12157,12160,12159,12162,12161,12164,12163,12166,12165,12168,12167,12170,12169,12172,12171,
24+
12174,12173,12176,12175,12178,12177,12180,12179,12182,12181,12184,12183,12186,12185,12188,12187,
25+
12190,12189,12192,12191,12194,12193,12196,12195,12198,12197,12200,12199,12202,12201,12204,12203,
26+
12206,12205,12208,12207,12210,12209,12212,12211,12214,12213,12216,12215,12218,12217,12220,12219,
27+
12222,12221,12224,12223,12226,12225,12228,12227,12230,12229,12232,12231,12234,12233,12236,12235,
28+
12238,12237,12240,12239,12242,12241,12244,12243,12246,12245,12248,12247,12250,12249,12252,12251,
29+
12254,12253,12256,12255,12258,12257,12260,12259,12262,12261,12264,12263,12266,12265,12268,12267,
30+
12270,12269,12272,12271,12274,12273,12276,12275,12278,12277,12280,12279,12282,12281,12284,12283,
31+
12286,12285,12288,12287,12290,12289,12292,12291,12294,12293,12296,12295,12298,12297,12300,12299,
32+
12302,12301,12304,12303,12306,12305,12308,12307,12310,12309,12312,12311,12314,12313,12316,12315,
33+
12318,12317,12320,12319,12322,12321,12324,12323,12326,12325,12328,12327,12330,12329,12332,12331,
34+
12334,12333,12336,12335,12338,12337,12340,12339,12439,12440,12441,12442,12443,12444,12445,12446,
35+
12447,12448,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462,
36+
12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,
37+
12479,12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,12493,12494,
38+
12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,
39+
12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,12525,12526,
40+
12527,12528,12529,12530,12531,12532,12533,13303,13304,13305,13306,13307,13308,13309,13310,13311,
41+
13312,13313,13314,13315,13316,13317,13318,13319,13320,13321,13322,13323,13324,13325,13326,13327,
42+
13328,13329,13330,13331,13332,13333,13334,13335,13336,13337,13338,13339,13340,13341,13342,13343,
43+
13344,13345,13346,13347,13348,13349,13350,13351,13352,13353,13354,13355,13356,13357,13358,13359,
44+
13360,13361,13362,13363,13364,13365,13366,13367,13368,13369,13370,13371,13372,13373,13374,13375,
45+
13376,13377,13378,13379,13380,13381,13382,13383,13384,13385,13386,13387,13388,13389,13390,13391,
46+
13392,13393,13394,13395,13396,13397]

src/ansys/dyna/core/pre/Server/kwprocess_pb2.py

Lines changed: 507 additions & 467 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ansys/dyna/core/pre/Server/kwprocess_pb2_grpc.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ def __init__(self, channel):
194194
request_serializer=kwprocess__pb2.BdySpcRequest.SerializeToString,
195195
response_deserializer=kwprocess__pb2.BdySpcReply.FromString,
196196
)
197+
self.CreateBdyTemp = channel.unary_unary(
198+
'/kwgrpc.kwC2S/CreateBdyTemp',
199+
request_serializer=kwprocess__pb2.BdyTempRequest.SerializeToString,
200+
response_deserializer=kwprocess__pb2.BdyTempReply.FromString,
201+
)
197202
self.CreateConstrainedJoint = channel.unary_unary(
198203
'/kwgrpc.kwC2S/CreateConstrainedJoint',
199204
request_serializer=kwprocess__pb2.ConstrainedJointRequest.SerializeToString,
@@ -774,6 +779,11 @@ def __init__(self, channel):
774779
request_serializer=kwprocess__pb2.EMEOSPermeabilityRequest.SerializeToString,
775780
response_deserializer=kwprocess__pb2.EMEOSPermeabilityReply.FromString,
776781
)
782+
self.CreateEMEOSTabulated1 = channel.unary_unary(
783+
'/kwgrpc.kwC2S/CreateEMEOSTabulated1',
784+
request_serializer=kwprocess__pb2.EMEOSTabulated1Request.SerializeToString,
785+
response_deserializer=kwprocess__pb2.EMEOSTabulated1Reply.FromString,
786+
)
777787
self.CreateFrequencyDomainFRF = channel.unary_unary(
778788
'/kwgrpc.kwC2S/CreateFrequencyDomainFRF',
779789
request_serializer=kwprocess__pb2.FrequencyDomainFRFRequest.SerializeToString,
@@ -1011,6 +1021,12 @@ def CreateBdySpc(self, request, context):
10111021
context.set_details('Method not implemented!')
10121022
raise NotImplementedError('Method not implemented!')
10131023

1024+
def CreateBdyTemp(self, request, context):
1025+
"""Missing associated documentation comment in .proto file."""
1026+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
1027+
context.set_details('Method not implemented!')
1028+
raise NotImplementedError('Method not implemented!')
1029+
10141030
def CreateConstrainedJoint(self, request, context):
10151031
"""---CONSTRAINED
10161032
"""
@@ -1720,6 +1736,12 @@ def CreateEMEOSPermeability(self, request, context):
17201736
context.set_details('Method not implemented!')
17211737
raise NotImplementedError('Method not implemented!')
17221738

1739+
def CreateEMEOSTabulated1(self, request, context):
1740+
"""Missing associated documentation comment in .proto file."""
1741+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
1742+
context.set_details('Method not implemented!')
1743+
raise NotImplementedError('Method not implemented!')
1744+
17231745
def CreateFrequencyDomainFRF(self, request, context):
17241746
"""---Frequency
17251747
"""
@@ -1916,6 +1938,11 @@ def add_kwC2SServicer_to_server(servicer, server):
19161938
request_deserializer=kwprocess__pb2.BdySpcRequest.FromString,
19171939
response_serializer=kwprocess__pb2.BdySpcReply.SerializeToString,
19181940
),
1941+
'CreateBdyTemp': grpc.unary_unary_rpc_method_handler(
1942+
servicer.CreateBdyTemp,
1943+
request_deserializer=kwprocess__pb2.BdyTempRequest.FromString,
1944+
response_serializer=kwprocess__pb2.BdyTempReply.SerializeToString,
1945+
),
19191946
'CreateConstrainedJoint': grpc.unary_unary_rpc_method_handler(
19201947
servicer.CreateConstrainedJoint,
19211948
request_deserializer=kwprocess__pb2.ConstrainedJointRequest.FromString,
@@ -2496,6 +2523,11 @@ def add_kwC2SServicer_to_server(servicer, server):
24962523
request_deserializer=kwprocess__pb2.EMEOSPermeabilityRequest.FromString,
24972524
response_serializer=kwprocess__pb2.EMEOSPermeabilityReply.SerializeToString,
24982525
),
2526+
'CreateEMEOSTabulated1': grpc.unary_unary_rpc_method_handler(
2527+
servicer.CreateEMEOSTabulated1,
2528+
request_deserializer=kwprocess__pb2.EMEOSTabulated1Request.FromString,
2529+
response_serializer=kwprocess__pb2.EMEOSTabulated1Reply.SerializeToString,
2530+
),
24992531
'CreateFrequencyDomainFRF': grpc.unary_unary_rpc_method_handler(
25002532
servicer.CreateFrequencyDomainFRF,
25012533
request_deserializer=kwprocess__pb2.FrequencyDomainFRFRequest.FromString,
@@ -3128,6 +3160,23 @@ def CreateBdySpc(request,
31283160
options, channel_credentials,
31293161
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
31303162

3163+
@staticmethod
3164+
def CreateBdyTemp(request,
3165+
target,
3166+
options=(),
3167+
channel_credentials=None,
3168+
call_credentials=None,
3169+
insecure=False,
3170+
compression=None,
3171+
wait_for_ready=None,
3172+
timeout=None,
3173+
metadata=None):
3174+
return grpc.experimental.unary_unary(request, target, '/kwgrpc.kwC2S/CreateBdyTemp',
3175+
kwprocess__pb2.BdyTempRequest.SerializeToString,
3176+
kwprocess__pb2.BdyTempReply.FromString,
3177+
options, channel_credentials,
3178+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
3179+
31313180
@staticmethod
31323181
def CreateConstrainedJoint(request,
31333182
target,
@@ -5100,6 +5149,23 @@ def CreateEMEOSPermeability(request,
51005149
options, channel_credentials,
51015150
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
51025151

5152+
@staticmethod
5153+
def CreateEMEOSTabulated1(request,
5154+
target,
5155+
options=(),
5156+
channel_credentials=None,
5157+
call_credentials=None,
5158+
insecure=False,
5159+
compression=None,
5160+
wait_for_ready=None,
5161+
timeout=None,
5162+
metadata=None):
5163+
return grpc.experimental.unary_unary(request, target, '/kwgrpc.kwC2S/CreateEMEOSTabulated1',
5164+
kwprocess__pb2.EMEOSTabulated1Request.SerializeToString,
5165+
kwprocess__pb2.EMEOSTabulated1Reply.FromString,
5166+
options, channel_credentials,
5167+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
5168+
51035169
@staticmethod
51045170
def CreateFrequencyDomainFRF(request,
51055171
target,

src/ansys/dyna/core/pre/Server/kwserver.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,23 +1225,7 @@ def CreateBdySpc(self, request, context):
12251225
birth = request.birth
12261226
death = request.death
12271227
# card0 = str(id)+","+heading
1228-
card1 = (
1229-
str(nid)
1230-
+ ","
1231-
+ str(cid)
1232-
+ ","
1233-
+ str(dofx)
1234-
+ ","
1235-
+ str(dofy)
1236-
+ ","
1237-
+ str(dofz)
1238-
+ ","
1239-
+ str(dofrx)
1240-
+ ","
1241-
+ str(dofry)
1242-
+ ","
1243-
+ str(dofrz)
1244-
)
1228+
card1 = str(nid)+ ","+ str(cid)+ ","+ str(dofx)+ ","+ str(dofy)+ ","+ str(dofz)+ ","+ str(dofrx)+ ","+ str(dofry)+ ","+ str(dofrz)
12451229
card2 = str(birth) + "," + str(death)
12461230
opcode = "*BOUNDARY_SPC_" + option1.upper()
12471231
if birthdeath:
@@ -1258,6 +1242,20 @@ def CreateBdySpc(self, request, context):
12581242
msg = "*BOUNDARY_SPC Created..."
12591243
print(msg)
12601244
return kwprocess_pb2.BdySpcReply(answer=0)
1245+
1246+
def CreateBdyTemp(self, request, context):
1247+
option = request.option
1248+
nid = request.nid
1249+
tlcid = request.tlcid
1250+
tmult = request.tmult
1251+
card1 = str(nid)+ ","+ str(tlcid)+ ","+ str(tmult)
1252+
opcode = "*BOUNDARY_TEMPERATURE_" + option.upper()
1253+
newk = opcode + "\n"
1254+
newk += card1 + "\n"
1255+
self.kwdproc.newkeyword(newk)
1256+
msg = "*BOUNDARY_TEMPERATURE Created..."
1257+
print(msg)
1258+
return kwprocess_pb2.BdyTempReply(answer=0)
12611259

12621260
# CONSTRAINED
12631261
def CreateConstrainedExtraNodes(self, request, context):
@@ -1338,7 +1336,8 @@ def CreateMatEM(self, request, context):
13381336
mid = request.mid
13391337
mtype = request.mtype
13401338
sigma = request.sigma
1341-
card1 = str(mid) + "," + str(mtype) + "," + str(sigma)
1339+
eosid = request.eosid
1340+
card1 = str(mid) + "," + str(mtype) + "," + str(sigma)+ "," + str(eosid)
13421341
opcode = "*EM_MAT_001"
13431342
newk = opcode + "\n" + card1
13441343
self.kwdproc.newkeyword(newk)
@@ -1729,7 +1728,7 @@ def CreateMatSPHIncompressibleStructure(self, request, context):
17291728
return kwprocess_pb2.MatSPHIncompressibleStructureReply(mid=mid)
17301729

17311730
def CreateMatThermalIsotropic(self, request, context):
1732-
mid = request.mid
1731+
mid = self.kwdproc.get_data(gdt.KWD_MAT_THERMAL_LASTID) + 1
17331732
tro = request.tro
17341733
tgrlc = request.tgrlc
17351734
tgmult = request.tgmult
@@ -2762,7 +2761,17 @@ def CreateEMEOSPermeability(self, request, context):
27622761
self.kwdproc.newkeyword(newk)
27632762
msg = "*EM_EOS_PERMEABILITY Created..."
27642763
print(msg)
2765-
return kwprocess_pb2.EMEOSPermeabilityReply(answer=0)
2764+
return kwprocess_pb2.EMEOSPermeabilityReply(id=0)
2765+
2766+
def CreateEMEOSTabulated1(self, request, context):
2767+
eosid = self.kwdproc.get_data(gdt.KWD_EM_EOS_LASTID) + 1
2768+
lcid = request.lcid
2769+
card1 = str(eosid) + "," + str(lcid)
2770+
newk = "*EM_EOS_TABULATED1\n" + card1
2771+
self.kwdproc.newkeyword(newk)
2772+
msg = "*EM_EOS_TABULATED1 Created..."
2773+
print(msg)
2774+
return kwprocess_pb2.EMEOSTabulated1Reply(id=eosid)
27662775

27672776
def ALECreateStructuredMesh(self, request, context):
27682777
nbid = request.nbid
26.2 KB
Binary file not shown.
23 KB
Binary file not shown.
23.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)