Skip to content

Commit 04dafbb

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent cbb2d5c commit 04dafbb

File tree

1 file changed

+69
-72
lines changed

1 file changed

+69
-72
lines changed

examples/Metalforming/metalforming.py

Lines changed: 69 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,37 @@
66
``ls-dyna_smp_d_R13.0_365-gf8a97bda2a_winx64_ifort190.exe``.
77
88
"""
9+
910
###############################################################################
1011
# Perform required imports
1112
# ~~~~~~~~~~~~~~~~~~~~~~~~
1213
# Peform the required imports.
1314
import os
1415
import sys
1516

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
1819
from ansys.dyna.core.pre.dynamech import (
19-
DynaMech,
20-
PartSet,
21-
Curve,
22-
ShellPart,
23-
NodeSet,
20+
DOF,
21+
AnalysisType,
22+
BulkViscosity,
2423
Contact,
25-
Motion,
24+
ContactCategory,
2625
ContactSurface,
27-
ShellFormulation,
2826
ContactType,
29-
ContactCategory,
30-
AnalysisType,
31-
MetalFormingAnalysis,
32-
DOF,
33-
BulkViscosity,
27+
Curve,
28+
DynaMech,
3429
EnergyFlag,
3530
HourglassControl,
31+
MetalFormingAnalysis,
32+
Motion,
33+
NodeSet,
34+
PartSet,
35+
ShellFormulation,
36+
ShellPart,
3637
)
37-
from ansys.dyna.core.pre.dynamaterial import (
38-
MatRigid,
39-
MatTransverselyAnisotropicElasticPlastic,
40-
)
41-
from ansys.dyna.core.pre import examples
4238
from ansys.dyna.core.pre.misc import check_valid_ip
39+
4340
# sphinx_gallery_thumbnail_path = '_static/pre/explicit/ball_plate.png'
4441

4542
###############################################################################
@@ -48,9 +45,9 @@
4845
# Before starting the ``pre`` service, you must ensure that the Docker container
4946
# for this service has been started. For more information, see "Start the Docker
5047
# 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
5451
# refering to the README.rst file in this server package.
5552
#
5653
# Once the ``pre`` service is running, you can connect a client to it using
@@ -60,7 +57,7 @@
6057
hostname = "localhost"
6158
if len(sys.argv) > 1 and check_valid_ip(sys.argv[1]):
6259
hostname = sys.argv[1]
63-
solution = launch_dyna(ip = hostname)
60+
solution = launch_dyna(ip=hostname)
6461

6562
###############################################################################
6663
# Start the solution workflow
@@ -71,49 +68,49 @@
7168
#
7269
fns = []
7370
path = examples.mf_simple_roll + os.sep
74-
fns.append(path+"model.k")
71+
fns.append(path + "model.k")
7572
solution.open_files(fns)
7673

7774
###############################################################################
7875
# Create database and control cards
7976
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8077
# For the D3plots, set simulation termination time, simulation timestep, and
81-
# output frequency.
78+
# output frequency.
8279

8380
solution.set_termination(termination_time=0.05)
8481

8582
mf = DynaMech(AnalysisType.NONE)
8683
solution.add(mf)
8784

8885
mfanalysis = MetalFormingAnalysis()
89-
mfanalysis.set_springback(PartSet([1]),100)
86+
mfanalysis.set_springback(PartSet([1]), 100)
9087
mfanalysis.set_rigid_body_nodes_fast_update(fast_update=1)
9188
mf.add(mfanalysis)
9289

9390
mf.set_timestep(timestep_size_for_mass_scaled=-7e-7)
9491
mf.set_accuracy()
9592
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+
)
10098
mf.set_hourglass(HourglassControl.FLANAGAN_BELYTSCHKO_EXACT_VOLUME_INTEGRATION_SOLID)
10199
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+
)
117114

118115
###############################################################################
119116
# Define materials
@@ -145,14 +142,15 @@
145142
translational_constraint=7,
146143
rotational_constraint=7,
147144
)
148-
crv = Curve(x=[0, 1],y=[0, 13])
145+
crv = Curve(x=[0, 1], y=[0, 13])
149146
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,
153150
anisotropic_hardening_parameter=-1.5930001,
154-
curve_stress = crv)
155-
151+
curve_stress=crv,
152+
)
153+
156154

157155
###############################################################################
158156
# Define section properties and assign materials
@@ -202,36 +200,36 @@
202200

203201
mfcontact = Contact(type=ContactType.FORMING, category=ContactCategory.ONE_WAY_SURFACE_TO_SURFACE)
204202
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)
208206
mfcontact.set_slave_surface(surf1)
209207
mfcontact.set_master_surface(surf2)
210208
mf.contacts.add(mfcontact)
211209

212210
mfcontact = Contact(type=ContactType.FORMING, category=ContactCategory.ONE_WAY_SURFACE_TO_SURFACE)
213211
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)
217215
mfcontact.set_slave_surface(surf1)
218216
mfcontact.set_master_surface(surf2)
219217
mf.contacts.add(mfcontact)
220218

221219
mfcontact = Contact(type=ContactType.FORMING, category=ContactCategory.ONE_WAY_SURFACE_TO_SURFACE)
222220
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)
226224
mfcontact.set_slave_surface(surf1)
227225
mfcontact.set_master_surface(surf2)
228226
mf.contacts.add(mfcontact)
229227

230228
mfcontact = Contact(type=ContactType.FORMING, category=ContactCategory.ONE_WAY_SURFACE_TO_SURFACE)
231229
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)
235233
mfcontact.set_slave_surface(surf1)
236234
mfcontact.set_master_surface(surf2)
237235
mf.contacts.add(mfcontact)
@@ -241,19 +239,19 @@
241239
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
242240
# Constrain the nodes in a list of single point constraints (spc).
243241

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)
246244

247245
mf.boundaryconditions.create_imposed_motion(
248246
PartSet([2]),
249-
Curve(x=[0,100], y=[600,600]),
247+
Curve(x=[0, 100], y=[600, 600]),
250248
dof=DOF.Y_ROTATIONAL,
251249
motion=Motion.VELOCITY,
252250
scalefactor=-1,
253251
)
254252
mf.boundaryconditions.create_imposed_motion(
255253
PartSet([3]),
256-
Curve(x=[0,100], y=[600,600]),
254+
Curve(x=[0, 100], y=[600, 600]),
257255
dof=DOF.Y_ROTATIONAL,
258256
motion=Motion.VELOCITY,
259257
scalefactor=1,
@@ -263,8 +261,7 @@
263261
# ~~~~~~~~~~~~~~~~~~~~~~~~~
264262

265263
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])
268265
)
269266

270267
###############################################################################
@@ -282,9 +279,9 @@
282279
# Download output file from Docker image for the server to
283280
# your local ``<working directory>/output/`` location.
284281

285-
serveroutfile = '/'.join((serverpath,"model.k"))
282+
serveroutfile = "/".join((serverpath, "model.k"))
286283
downloadpath = os.path.join(os.getcwd(), "output")
287284
if not os.path.exists(downloadpath):
288285
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

Comments
 (0)