|
6 | 6 | ``ls-dyna_smp_d_R13.0_365-gf8a97bda2a_winx64_ifort190.exe``. |
7 | 7 |
|
8 | 8 | """ |
| 9 | + |
9 | 10 | ############################################################################### |
10 | 11 | # Perform required imports |
11 | 12 | # ~~~~~~~~~~~~~~~~~~~~~~~~ |
12 | 13 | # Peform the required imports. |
13 | 14 | import os |
14 | 15 | import sys |
15 | 16 |
|
16 | | - |
17 | | -from ansys.dyna.core.pre import launch_dyna |
| 17 | +from ansys.dyna.core.pre import examples, launch_dyna |
| 18 | +from ansys.dyna.core.pre.dynamaterial import MatRigid, MatTransverselyAnisotropicElasticPlastic |
18 | 19 | from ansys.dyna.core.pre.dynamech import ( |
19 | | - DynaMech, |
20 | | - PartSet, |
21 | | - Curve, |
22 | | - ShellPart, |
23 | | - NodeSet, |
| 20 | + DOF, |
| 21 | + AnalysisType, |
| 22 | + BulkViscosity, |
24 | 23 | Contact, |
25 | | - Motion, |
| 24 | + ContactCategory, |
26 | 25 | ContactSurface, |
27 | | - ShellFormulation, |
28 | 26 | ContactType, |
29 | | - ContactCategory, |
30 | | - AnalysisType, |
31 | | - MetalFormingAnalysis, |
32 | | - DOF, |
33 | | - BulkViscosity, |
| 27 | + Curve, |
| 28 | + DynaMech, |
34 | 29 | EnergyFlag, |
35 | 30 | HourglassControl, |
| 31 | + MetalFormingAnalysis, |
| 32 | + Motion, |
| 33 | + NodeSet, |
| 34 | + PartSet, |
| 35 | + ShellFormulation, |
| 36 | + ShellPart, |
36 | 37 | ) |
37 | | -from ansys.dyna.core.pre.dynamaterial import ( |
38 | | - MatRigid, |
39 | | - MatTransverselyAnisotropicElasticPlastic, |
40 | | -) |
41 | | -from ansys.dyna.core.pre import examples |
42 | 38 | from ansys.dyna.core.pre.misc import check_valid_ip |
| 39 | + |
43 | 40 | # sphinx_gallery_thumbnail_path = '_static/pre/explicit/ball_plate.png' |
44 | 41 |
|
45 | 42 | ############################################################################### |
|
48 | 45 | # Before starting the ``pre`` service, you must ensure that the Docker container |
49 | 46 | # for this service has been started. For more information, see "Start the Docker |
50 | 47 | # container for the ``pre`` service" in https://dyna.docs.pyansys.com/version/stable/index.html. |
51 | | -# |
52 | | -# The ``pre`` service can also be started locally, please download the latest version of |
53 | | -# ansys-pydyna-pre-server.zip package from https://github.com/ansys/pydyna/releases and start it |
| 48 | +# |
| 49 | +# The ``pre`` service can also be started locally, please download the latest version of |
| 50 | +# ansys-pydyna-pre-server.zip package from https://github.com/ansys/pydyna/releases and start it |
54 | 51 | # refering to the README.rst file in this server package. |
55 | 52 | # |
56 | 53 | # Once the ``pre`` service is running, you can connect a client to it using |
|
60 | 57 | hostname = "localhost" |
61 | 58 | if len(sys.argv) > 1 and check_valid_ip(sys.argv[1]): |
62 | 59 | hostname = sys.argv[1] |
63 | | -solution = launch_dyna(ip = hostname) |
| 60 | +solution = launch_dyna(ip=hostname) |
64 | 61 |
|
65 | 62 | ############################################################################### |
66 | 63 | # Start the solution workflow |
|
71 | 68 | # |
72 | 69 | fns = [] |
73 | 70 | path = examples.mf_simple_roll + os.sep |
74 | | -fns.append(path+"model.k") |
| 71 | +fns.append(path + "model.k") |
75 | 72 | solution.open_files(fns) |
76 | 73 |
|
77 | 74 | ############################################################################### |
78 | 75 | # Create database and control cards |
79 | 76 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
80 | 77 | # For the D3plots, set simulation termination time, simulation timestep, and |
81 | | -# output frequency. |
| 78 | +# output frequency. |
82 | 79 |
|
83 | 80 | solution.set_termination(termination_time=0.05) |
84 | 81 |
|
85 | 82 | mf = DynaMech(AnalysisType.NONE) |
86 | 83 | solution.add(mf) |
87 | 84 |
|
88 | 85 | mfanalysis = MetalFormingAnalysis() |
89 | | -mfanalysis.set_springback(PartSet([1]),100) |
| 86 | +mfanalysis.set_springback(PartSet([1]), 100) |
90 | 87 | mfanalysis.set_rigid_body_nodes_fast_update(fast_update=1) |
91 | 88 | mf.add(mfanalysis) |
92 | 89 |
|
93 | 90 | mf.set_timestep(timestep_size_for_mass_scaled=-7e-7) |
94 | 91 | mf.set_accuracy() |
95 | 92 | mf.set_bulk_viscosity(bulk_viscosity_type=BulkViscosity.STANDARD_BULK_VISCOSITY_SHELL) |
96 | | -mf.set_energy(hourglass_energy=EnergyFlag.COMPUTED, |
97 | | - rigidwall_energy=EnergyFlag.NOT_COMPUTED, |
98 | | - sliding_interface_energy=EnergyFlag.COMPUTED |
99 | | - ) |
| 93 | +mf.set_energy( |
| 94 | + hourglass_energy=EnergyFlag.COMPUTED, |
| 95 | + rigidwall_energy=EnergyFlag.NOT_COMPUTED, |
| 96 | + sliding_interface_energy=EnergyFlag.COMPUTED, |
| 97 | +) |
100 | 98 | mf.set_hourglass(HourglassControl.FLANAGAN_BELYTSCHKO_EXACT_VOLUME_INTEGRATION_SOLID) |
101 | 99 | mf.set_output(print_suppression_d3hsp=True) |
102 | | -mf.create_control_shell(esort=1,istupd=1) |
103 | | -mf.create_control_contact(initial_penetration_check = 2, |
104 | | - shlthk = 1, |
105 | | - penalty_stiffness_option = 4, |
106 | | - orien = 4, |
107 | | - penetration_check_multiplier = 1.0) |
108 | | -mf.set_adaptive(time_interval_refinement=2.5e-4, |
109 | | - adaptive_error_tolerance=5.0, |
110 | | - adaptive_type = 2, |
111 | | - generate_adaptive_mesh_at_exit = 1, |
112 | | - min_shell_size = 1.83, |
113 | | - h_adaptivity_pass_flag = 1, |
114 | | - shell_h_adapt = 5.0, |
115 | | - fission_control_flag = -1, |
116 | | - ) |
| 100 | +mf.create_control_shell(esort=1, istupd=1) |
| 101 | +mf.create_control_contact( |
| 102 | + initial_penetration_check=2, shlthk=1, penalty_stiffness_option=4, orien=4, penetration_check_multiplier=1.0 |
| 103 | +) |
| 104 | +mf.set_adaptive( |
| 105 | + time_interval_refinement=2.5e-4, |
| 106 | + adaptive_error_tolerance=5.0, |
| 107 | + adaptive_type=2, |
| 108 | + generate_adaptive_mesh_at_exit=1, |
| 109 | + min_shell_size=1.83, |
| 110 | + h_adaptivity_pass_flag=1, |
| 111 | + shell_h_adapt=5.0, |
| 112 | + fission_control_flag=-1, |
| 113 | +) |
117 | 114 |
|
118 | 115 | ############################################################################### |
119 | 116 | # Define materials |
|
145 | 142 | translational_constraint=7, |
146 | 143 | rotational_constraint=7, |
147 | 144 | ) |
148 | | -crv = Curve(x=[0, 1],y=[0, 13]) |
| 145 | +crv = Curve(x=[0, 1], y=[0, 13]) |
149 | 146 | matblank = MatTransverselyAnisotropicElasticPlastic( |
150 | | - mass_density=7.9e-09, |
151 | | - young_modulus=2.07e5, |
152 | | - yield_stress=201.3, |
| 147 | + mass_density=7.9e-09, |
| 148 | + young_modulus=2.07e5, |
| 149 | + yield_stress=201.3, |
153 | 150 | anisotropic_hardening_parameter=-1.5930001, |
154 | | - curve_stress = crv) |
155 | | - |
| 151 | + curve_stress=crv, |
| 152 | +) |
| 153 | + |
156 | 154 |
|
157 | 155 | ############################################################################### |
158 | 156 | # Define section properties and assign materials |
|
202 | 200 |
|
203 | 201 | mfcontact = Contact(type=ContactType.FORMING, category=ContactCategory.ONE_WAY_SURFACE_TO_SURFACE) |
204 | 202 | mfcontact.set_friction_coefficient(static=0.125, dynamic=0) |
205 | | -mfcontact.set_extra_coefficient(viscous_damping = 20) |
206 | | -surf1 = ContactSurface(PartSet([1]),save_interface_force = 1) |
207 | | -surf2 = ContactSurface(PartSet([2]),save_interface_force = 1) |
| 203 | +mfcontact.set_extra_coefficient(viscous_damping=20) |
| 204 | +surf1 = ContactSurface(PartSet([1]), save_interface_force=1) |
| 205 | +surf2 = ContactSurface(PartSet([2]), save_interface_force=1) |
208 | 206 | mfcontact.set_slave_surface(surf1) |
209 | 207 | mfcontact.set_master_surface(surf2) |
210 | 208 | mf.contacts.add(mfcontact) |
211 | 209 |
|
212 | 210 | mfcontact = Contact(type=ContactType.FORMING, category=ContactCategory.ONE_WAY_SURFACE_TO_SURFACE) |
213 | 211 | mfcontact.set_friction_coefficient(static=0.125, dynamic=0) |
214 | | -mfcontact.set_extra_coefficient(viscous_damping = 20) |
215 | | -surf1 = ContactSurface(PartSet([1]),save_interface_force = 1) |
216 | | -surf2 = ContactSurface(PartSet([3]),save_interface_force = 1) |
| 212 | +mfcontact.set_extra_coefficient(viscous_damping=20) |
| 213 | +surf1 = ContactSurface(PartSet([1]), save_interface_force=1) |
| 214 | +surf2 = ContactSurface(PartSet([3]), save_interface_force=1) |
217 | 215 | mfcontact.set_slave_surface(surf1) |
218 | 216 | mfcontact.set_master_surface(surf2) |
219 | 217 | mf.contacts.add(mfcontact) |
220 | 218 |
|
221 | 219 | mfcontact = Contact(type=ContactType.FORMING, category=ContactCategory.ONE_WAY_SURFACE_TO_SURFACE) |
222 | 220 | mfcontact.set_friction_coefficient(static=0.125, dynamic=0) |
223 | | -mfcontact.set_extra_coefficient(viscous_damping = 20) |
224 | | -surf1 = ContactSurface(PartSet([1]),save_interface_force = 1) |
225 | | -surf2 = ContactSurface(PartSet([4]),save_interface_force = 1) |
| 221 | +mfcontact.set_extra_coefficient(viscous_damping=20) |
| 222 | +surf1 = ContactSurface(PartSet([1]), save_interface_force=1) |
| 223 | +surf2 = ContactSurface(PartSet([4]), save_interface_force=1) |
226 | 224 | mfcontact.set_slave_surface(surf1) |
227 | 225 | mfcontact.set_master_surface(surf2) |
228 | 226 | mf.contacts.add(mfcontact) |
229 | 227 |
|
230 | 228 | mfcontact = Contact(type=ContactType.FORMING, category=ContactCategory.ONE_WAY_SURFACE_TO_SURFACE) |
231 | 229 | mfcontact.set_friction_coefficient(static=0.125, dynamic=0) |
232 | | -mfcontact.set_extra_coefficient(viscous_damping = 20) |
233 | | -surf1 = ContactSurface(PartSet([1]),save_interface_force = 1) |
234 | | -surf2 = ContactSurface(PartSet([5]),save_interface_force = 1) |
| 230 | +mfcontact.set_extra_coefficient(viscous_damping=20) |
| 231 | +surf1 = ContactSurface(PartSet([1]), save_interface_force=1) |
| 232 | +surf2 = ContactSurface(PartSet([5]), save_interface_force=1) |
235 | 233 | mfcontact.set_slave_surface(surf1) |
236 | 234 | mfcontact.set_master_surface(surf2) |
237 | 235 | mf.contacts.add(mfcontact) |
|
241 | 239 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
242 | 240 | # Constrain the nodes in a list of single point constraints (spc). |
243 | 241 |
|
244 | | -spc = [600,593] |
245 | | -mf.boundaryconditions.create_spc(NodeSet(spc),tx = False, tz = False,ry=False) |
| 242 | +spc = [600, 593] |
| 243 | +mf.boundaryconditions.create_spc(NodeSet(spc), tx=False, tz=False, ry=False) |
246 | 244 |
|
247 | 245 | mf.boundaryconditions.create_imposed_motion( |
248 | 246 | PartSet([2]), |
249 | | - Curve(x=[0,100], y=[600,600]), |
| 247 | + Curve(x=[0, 100], y=[600, 600]), |
250 | 248 | dof=DOF.Y_ROTATIONAL, |
251 | 249 | motion=Motion.VELOCITY, |
252 | 250 | scalefactor=-1, |
253 | 251 | ) |
254 | 252 | mf.boundaryconditions.create_imposed_motion( |
255 | 253 | PartSet([3]), |
256 | | - Curve(x=[0,100], y=[600,600]), |
| 254 | + Curve(x=[0, 100], y=[600, 600]), |
257 | 255 | dof=DOF.Y_ROTATIONAL, |
258 | 256 | motion=Motion.VELOCITY, |
259 | 257 | scalefactor=1, |
|
263 | 261 | # ~~~~~~~~~~~~~~~~~~~~~~~~~ |
264 | 262 |
|
265 | 263 | mf.loads.create_nodal_force( |
266 | | - NodeSet([695,696,697,698,694,693,692]), |
267 | | - load_curve = Curve(x=[0,0.015,0.016,100],y=[100,100,0,0]) |
| 264 | + NodeSet([695, 696, 697, 698, 694, 693, 692]), load_curve=Curve(x=[0, 0.015, 0.016, 100], y=[100, 100, 0, 0]) |
268 | 265 | ) |
269 | 266 |
|
270 | 267 | ############################################################################### |
|
282 | 279 | # Download output file from Docker image for the server to |
283 | 280 | # your local ``<working directory>/output/`` location. |
284 | 281 |
|
285 | | -serveroutfile = '/'.join((serverpath,"model.k")) |
| 282 | +serveroutfile = "/".join((serverpath, "model.k")) |
286 | 283 | downloadpath = os.path.join(os.getcwd(), "output") |
287 | 284 | if not os.path.exists(downloadpath): |
288 | 285 | os.makedirs(downloadpath) |
289 | | -downloadfile = os.path.join(downloadpath,"model.k") |
290 | | -solution.download(serveroutfile,downloadfile) |
| 286 | +downloadfile = os.path.join(downloadpath, "model.k") |
| 287 | +solution.download(serveroutfile, downloadfile) |
0 commit comments