@@ -77,98 +77,105 @@ Usage
77
77
=====
78
78
Here is a basic preprocessing example:
79
79
80
+ Get the input file from "pydyna\\ src\\ ansys\\ dyna\\ core\\ pre\\ examples\\ explicit\\ ball_plate\\ ball_plate.k"
81
+
82
+ The follow example can be obtained from "pydyna\e xamples\E xplicit\b all_plate.py"
83
+
80
84
.. code :: python
81
85
82
86
import os
83
87
import sys
84
88
from ansys.dyna.core.pre.dynasolution import DynaSolution
85
- from ansys.dyna.core.pre.dynaicfd import (
86
- DynaICFD,
87
- ICFDAnalysis,
88
- MatICFD,
89
- ICFDPart,
90
- ICFDDOF ,
91
- Curve,
92
- ICFDVolumePart,
93
- MeshedVolume,
89
+ from ansys.dyna.core.pre.dynamech import (
90
+ DynaMech,
91
+ Velocity,
92
+ PartSet,
93
+ ShellPart,
94
+ SolidPart,
95
+ NodeSet,
96
+ Contact,
97
+ ContactSurface,
98
+ ShellFormulation,
99
+ SolidFormulation,
100
+ ContactType,
101
+ AnalysisType
102
+ )
103
+ from ansys.dyna.core.pre.dynamaterial import (
104
+ MatRigid,
105
+ MatPiecewiseLinearPlasticity,
94
106
)
95
107
from ansys.dyna.core.pre import examples
96
- # sphinx_gallery_thumbnail_path = '_static/pre/icfd/cylinderflow.png'
97
108
98
109
hostname = " localhost"
99
110
if len (sys.argv) > 1 :
100
111
hostname = sys.argv[1 ]
112
+ solution = DynaSolution(hostname)
101
113
102
- icfd_solution = DynaSolution(hostname)
103
- # Import the initial mesh data(nodes and elements)
104
114
fns = []
105
- path = os.getcwd()+ os.sep
106
- fns.append(path+ " cylinder_flow.k" )
107
- icfd_solution.open_files(fns)
108
- # Set total time of simulation
109
- icfd_solution.set_termination(termination_time = 100 )
110
-
111
- icfd = DynaICFD()
112
- icfd_solution.add(icfd)
113
-
114
- icfdanalysis = ICFDAnalysis()
115
- icfdanalysis.set_timestep()
116
- icfd.add(icfdanalysis)
117
-
118
- # define model
119
- mat = MatICFD(flow_density = 1.0 , dynamic_viscosity = 0.005 )
120
-
121
- part_inflow = ICFDPart(1 )
122
- part_inflow.set_material(mat)
123
- part_inflow.set_prescribed_velocity(dof = ICFDDOF .X, motion = Curve(x = [0 , 10000 ], y = [1 , 1 ]))
124
- part_inflow.set_prescribed_velocity(dof = ICFDDOF .Y, motion = Curve(x = [0 , 10000 ], y = [0 , 0 ]))
125
- icfd.parts.add(part_inflow)
126
-
127
- part_outflow = ICFDPart(2 )
128
- part_outflow.set_material(mat)
129
- part_outflow.set_prescribed_pressure(pressure = Curve(x = [0 , 10000 ], y = [0 , 0 ]))
130
- icfd.parts.add(part_outflow)
131
-
132
- part_symmetric = ICFDPart(3 )
133
- part_symmetric.set_material(mat)
134
- part_symmetric.set_free_slip()
135
- icfd.parts.add(part_symmetric)
136
-
137
- part_wall = ICFDPart(4 )
138
- part_wall.set_material(mat)
139
- part_wall.set_non_slip()
140
- part_wall.compute_drag_force()
141
- part_wall.set_boundary_layer(number = 3 )
142
- icfd.parts.add(part_wall)
143
-
144
- partvol = ICFDVolumePart(surfaces = [1 , 2 , 3 , 4 ])
145
- partvol.set_material(mat)
146
- icfd.parts.add(partvol)
147
- # define the volume space that will be meshed,The boundaries
148
- # of the volume are the surfaces "spids"
149
- meshvol = MeshedVolume(surfaces = [1 , 2 , 3 , 4 ])
150
- icfd.add(meshvol)
151
-
152
- icfd_solution.create_database_binary(dt = 1 )
153
- serverpath = icfd_solution.save_file()
154
- serveroutfile = ' /' .join((serverpath," cylinder_flow.k" ))
115
+ path = examples.ball_plate + os.sep
116
+ fns.append(path+ " ball_plate.k" )
117
+ solution.open_files(fns)
118
+
119
+ solution.set_termination(termination_time = 10 )
120
+
121
+ ballplate = DynaMech(AnalysisType.NONE )
122
+ solution.add(ballplate)
123
+
124
+ matrigid = MatRigid(mass_density = 7.83e-6 , young_modulus = 207 , poisson_ratio = 0.3 )
125
+ matplastic = MatPiecewiseLinearPlasticity(mass_density = 7.83e-6 , young_modulus = 207 , yield_stress = 0.2 , tangent_modulus = 2 )
126
+
127
+ plate = ShellPart(1 )
128
+ plate.set_element_formulation(ShellFormulation.BELYTSCHKO_TSAY )
129
+ plate.set_material(matplastic)
130
+ plate.set_thickness(1 )
131
+ plate.set_integration_points(5 )
132
+ ballplate.parts.add(plate)
133
+
134
+ ball = SolidPart(2 )
135
+ ball.set_material(matrigid)
136
+ ball.set_element_formulation(SolidFormulation.CONSTANT_STRESS_SOLID_ELEMENT )
137
+ ballplate.parts.add(ball)
138
+
139
+ selfcontact = Contact(type = ContactType.AUTOMATIC )
140
+ surf1 = ContactSurface(PartSet([1 , 2 ]))
141
+ selfcontact.set_slave_surface(surf1)
142
+ ballplate.contacts.add(selfcontact)
143
+
144
+ spc = [34 ,35 ,51 ,52 ,68 ,69 ,85 ,86 ,102 ,103 ,119 ,120 ,136 ,137 ,153 ,154 ,170 ,171 ,187 ,188 ,204 ,205 ,221 ,222 ,238 ,239 ,255 ,256 ]
145
+ for i in range (1 ,19 ):
146
+ spc.append(i)
147
+ for i in range (272 ,290 ):
148
+ spc.append(i)
149
+ ballplate.boundaryconditions.create_spc(NodeSet(spc),rx = False ,ry = False ,rz = False )
150
+
151
+ for i in range (1 ,1652 ):
152
+ ballplate.initialconditions.create_velocity_node(i,trans = Velocity(0 , 0 , - 10 ))
153
+
154
+ solution.set_output_database(glstat = 0.1 , matsum = 0.1 , sleout = 0.1 )
155
+ solution.create_database_binary(dt = 1 )
156
+ serverpath = solution.save_file()
157
+
158
+ serveroutfile = ' /' .join((serverpath," ball_plate.k" ))
155
159
downloadpath = os.path.join(os.getcwd(), " output" )
156
160
if not os.path.exists(downloadpath):
157
161
os.makedirs(downloadpath)
158
- downloadfile = os.path.join(downloadpath," cylinder_flow .k" )
159
- icfd_solution .download(serveroutfile,downloadfile)
162
+ downloadfile = os.path.join(downloadpath," ball_plate .k" )
163
+ solution .download(serveroutfile,downloadfile)
160
164
161
165
Here is a basic solving example:
162
166
167
+ The follow example can be obtained from "pydyna\\ examples\\ solver\\ ball_plate_solver.py"
168
+
163
169
.. code :: python
164
170
171
+ import ansys.dyna.core.solver as solver
172
+
165
173
hostname = " localhost"
166
174
port = " 5000"
167
- import ansys.dyna.core.solver as solver
168
175
dyna= solver.DynaSolver(hostname,port) # connect to the container
169
- dyna.push(" cylinder_flow .k" ) # push an input file
176
+ dyna.push(" ./output/ball_plate .k" ) # push an input file
170
177
dyna.start(4 ) # start 4 ranks of mppdyna
171
- dyna.run(" i=./output/cylinder_flow .k memory=10m ncycle=20000" ) # begin execution
178
+ dyna.run(" i=ball_plate .k memory=10m ncycle=20000" ) # begin execution
172
179
173
180
Here is a basic postprocessing example:
174
181
0 commit comments