You are on page 1of 25

Tutorial: Projectile Moving Inside a Barrel

Introduction
The purpose of this tutorial is to illustrate how to set up and solve a problem using the following two features in FLUENT. Moving Deforming Mesh (MDM) using the layering algorithm. User-dened real gas law. The problem involves a projectile moving through a barrel and out of the muzzle. The ow is assumed to be inviscid. In this tutorial you will learn how to: Read a mesh le for performing an MDM calculation. Compile a UDF for the projectile motion and the Abel-Nobel real gas law. Set up the moving zones and hook the UDF in FLUENT. Run an unsteady calculation for the problem using coupled solver and axisymmetry. Create animations.

Prerequisites
This tutorial assumes that you are familiar with the FLUENT interface and have completed Tutorial 1 from the FLUENT 6.1 Tutorial Guide. Some of the basic steps in the setup and solution procedures will not be shown explicitly. You should be familiar with the dynamic mesh model. If you are not, please review Section 9.6: Dynamic Meshes in the FLUENT Users Guide. Note: Assuming that you are using a single processor machine with a clock speed of 2 GHz, this tutorial will take: One hour to work through it. An additional 6 hours for the calculations up to the uncorking of the projectile. An additional 43.5 hours for the calculations until the projectile leaves the eld of view.

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

Problem Description
A projectile weighing 120 grams is initially at rest inside a 20 mm caliber barrel. The gas inside the chamber is patched at a high pressure of 3000 atm and a temperature of 2700 K, and the projectile is released. The motion of the projectile is computed using a UDF based on FLUENTs Six Degree of Freedom UDF. In this case, only the pressure forces are considered, while drag and mechanical friction are neglected. The projectile is released at t=0. The Abel-Nobel equation of state is implemented using the user-dened real gas model.

Figure 1: Problem Schematic

Preparation
1. Copy the mesh le, projectile.msh.gz and the UDF source les, aneos.c and six dof property.c, to your working directory. 2. Start the 2D version of FLUENT.

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

Setup and Solution


Step 1: Grid 1. Read the grid le, projectile.msh.gz. File Read Case... FLUENT will read the le and report the progress in the console window. 2. Check the grid. Grid Check 3. Reorder the domain. Grid Reorder Domain Note: Perform this operation until the band width reduction is in the order of 1.0. 4. Scale the grid. Grid Scale... This mesh was created for a 155 mm barrel. To use this mesh for a 20 mm barrel in this tutorial, you need to scale it accordingly.

(a) Set the Scale Factors for both X and Y to 0.129. (b) Click Scale and close the panel.

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

5. Display the grid. Display Grid...

(a) Retain the default parameters. (b) Click Display and close the panel.

Figure 2: Grid Display

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

Figure 3: Dimensions and Zone Names This grid was created using GAMBIT. The region inside the barrel (on both sides of the projectile) and the region forming the extension of the muzzle are meshed with quads and lumped into one uid zone called fluid-mdm. The rest of the domain consists of one face that is disconnected from the other faces, and the corresponding zone is called fluid-static-outer. Thus, there are two sets of edges where the two uid regions meet. Each set is turned into an interface zone and allows you to dene a non-conformal interface at a later stage. Boundary layers are attached to the interface edge at the bottom of fluid-static-outer. This portion of the zone is meshed using quads. 6. Zoom in to the muzzle area (Figure 4).

Figure 4: Mesh Near the Muzzle

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

The entire zone, default-interior slides to the right, while keeping default-interior:001 stationary. At the same time, cells are created on the left (at the edge labeled breech in Figure 5), and destroyed on the right (at the edge labeled p-out-destruct in Figure 3). 7. Zoom in near the breech and projectile (Figure 5). Figure 5 shows the default-interior zone, which will move to the right. By specifying the rigid body motion of default-interior you are also specifying the rigid body motion of the walls belonging to the projectile (w-proj-base and w-proj-front). New quad cells are created at the left wall labeled breech. Conversely, quad cells are destroyed at the edge labeled p-out-destruct. The combination of moving one zone as a rigid body while creating and destroying cells is called layering.

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

Figure 5: Mesh Near the Breech and Chamber

8. View the zones, interface-inner and interface-outer (Figure 6). (a) Zoom out and under Surfaces, deselect default-interior, default-interior:001, and interface-outer to see where interface-inner is located. (b) Deselect interface-inner and select interface-outer.

Figure 6: Denition of the Non-Conformal Interface In Figure 6, the three red, dotted line segments represent the interface-outer zone and the seven blue line segments (including the bottoms of the muzzle brakes) represent the interface-inner zone.

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

Step 2: Models 1. Select the solver. Dene Models Solver...

(a) Under Solver, select Coupled and retain Implicit formulation. The real gas law works only with the Coupled solver. (b) Select Axisymmetric space and Unsteady and 1st-Order Implicit time formulation. MDM features currently work only with Unsteady and 1st-Order Implicit formulation. 2. Enable the Energy Equation. Dene Models Energy...

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

3. Set the viscous model to inviscid. Dene Models Viscous... (a) Enable Inviscid. 4. Set the units for pressure. Dene Units... (a) Under Quantities, select Pressure. (b) Under Units, select atm. 5. Set the Operating Pressure to 0. Dene Operating Conditions... (a) Under Operating Pressure, enter 0. This setting is usually used with the coupled solver, to avoid confusion between absolute and gauge pressures. With the operating pressure set to zero, the static and absolute pressures will be equivalent. Step 3: Compile the UDF This UDF (based on FLUENTs 6DOF UDF) is parallelized and has a restart capability, where previous velocities and Euler angles are written to a le. Although the UDF seems to be complicated, very few changes have been made to customize it for this tutorial. The Abel-Nobel Equation Of State (ANEOS) is implemented using FLUENTs user-dened real gas model. ANEOS is a truncated version of the Van der Waals equation of state; ANEOS is dened as: p(v b) = RT (1) where v is the specic volume and b is the covolume term, that represents the volume occupied by the molecules themselves. For this case, the initial specic volume is 0.00382 m3 /kg, while the covolume term is 0.001265 m3 /kg, indicating that about a fourth of the volume is occupied by the molecules themselves. With regard to the motion of the projectile, the UDF computes the total force (viscous plus pressure) acting on the projectile base and on the projectile nose, and then Newtons Second Law is used to compute the acceleration. The new velocity is then calculated using a nite dierence.

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

1. Compile the UDF. Dene User-Dened Functions Compiled...

(a) Under Source Files, click Add.... (b) In the Select File panel, select the source les, aneos.c and six dof property. (c) Under Library Name, enter libudf-6dof-real. (d) Click Build (do not click Load yet). FLUENT will set up the appropriate directory structure, and will compile the code for you. The progress of the compilation is shown on the FLUENT console window. Monitor the progress for compilation and linking errors. You can also see the log le in the working directory for the compilation history. (e) Load the library using text user interface (TUI) commands.
> /define/user-defined/real-gas/user-defined-real-gas-model use real gas? [no] y User Defined Realgas Library Name [""] libudf-6dof-real Opening user-defined realgas library "libudf-6dof-real"... Library "libudf-6dof-real/lnx86/2d/libudf.so" opened Setting material "air" to a real-gas... Loading Real-Ideal Library:

(f) In the Compiled UDFs panel, click Load. For more information on compiled UDFs, refer Section 7.3, Compiling a Source File Using the Compiled UDFs Panel, in the UDF Manual. Note: The Materials panel is no longer available, because the real gas law is now enabled.

10

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

Step 4: Boundary Conditions 1. Dene the boundary conditions. Dene Boundary Conditions... (a) Set the conditions for the pressure-inlet boundary. i. Under Zone, select p-inlet-outer and click Set....

ii. Set both Gauge Total Pressure and Supersonic/Initial Gauge Pressure to 1, and retain the Total Temperature at 300 K. (b) Set the conditions for the pressure-outlet boundary. i. Under Zone, select p-out-destruct and click Set....

ii. Set Gauge Pressure to 1 atm and retain Backow Total Temperature at 300 K. (c) Similarly, for p-out-outer, set Gauge Pressure to 1 atm and retain Backow Total Temperature at 300 K. (d) Set the conditions for upper-boundary boundary. i. Under Zone, select upper-boundary, and change the Type to pressure-outlet. ii. Click Yes in the Question dialog box that opens. 11

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

iii. Set Gauge Pressure to 1 atm and retain Backow Total Temperature at 300 K. (e) Retain the default settings for all the walls, i.e., tangency for momentum and zero heat ux for thermal and close the Boundary Conditions panel. 2. Dene the non-conformal interface. Dene Grid Interfaces...

(a) Under Grid Interface, enter interface. (b) Under Interface Zone 1, select interface-inner and under Interface Zone 2, select interface-outer (c) Click Create. Step 5: Dynamic Mesh Setup 1. Activate dynamic mesh motion and specify the associated parameters. Dene Dynamic Mesh Parameters... (a) Under Models, enable Dynamic Mesh and Six DOF Solver. The panel will expand to show additional parameters. (b) Under Mesh Methods, deselect Smoothing and select Layering. (c) Click on the Layering tab and set the Split Factor and Collapse Factor to 0.4. These factors indicate that a new layer of cells is created when the preceding layer has stretched beyond 1.4 times the ideal height, and that a layer is destroyed when the last layer has shrunk to a height less than 0.6 times the ideal height.

12

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

2. Specify the rigid body motion for the projectile and surrounding uid. By specifying the motion of the uid zone, uid-mdm, you are specifying the motion of the quad cells and of the projectile itself (i.e., the two zones w-proj-base and w-projfront). Dene Dynamic Mesh Zones...

(a) In the Zone Names list, select uid-mdm. (b) Retain Rigid Body as the motion Type. (c) In the Motion Attributes tab, ensure that under Six DOF Solver Options, On is enabled. (d) Ensure that under Six DOF UDF, projectile::libudf-6dof-real is selected. and click Create. The six dof::libudf-6dof-real UDF denes the rigid body motion. This will move the face that hosts the quad cells, together with the edges (wall-object and defaultinterior).

c Fluent Inc. March 27, 2006

13

Projectile Moving Inside a Barrel

3. Specify the stationary zone where new cell layers are created. (a) In the Zone Names list, select breech. (b) Under motion Type, select Stationary. (c) Under Meshing Options, specify the Cell Height as 0.000645 m and click Create. This is the axial dimension of the cells near the breech. This boundary zone thus becomes the location where new cells are created. 4. Specify the stationary zone where old cell layers are destroyed. (a) In the Zone Names list, select p-out-destruct. (b) Retain the motion Type as Stationary, Cell Height as 0.000645, and click Create. 5. Specify conditions for surfaces of projectile. (a) In the Zone Names list, select w-proj-base. (b) Under Type, enable Rigid body. (c) Click on the Meshing Options tab and set Cell Height to 0.000645. (d) Click Create. (e) In the Zone Names list, select w-proj-front. (f) Under Type, retain Rigid body. (g) In the Meshing Options tab, retain Cell Height at 0.000645. (h) Click Create. Step 6: Initial Solution 1. Set the upper limits for pressure and temperature. Solve Controls Limits...

(a) Set the Maximum Absolute Pressure to 3500 and retain Maximum Static Temperature at 5000 and click OK.

14

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

2. Initialize the solution. Solve Initialize Initialize... (a) Under Compute From, select p-inlet-outer. (b) Click Init and close the panel. 3. Dene an adaption register. Adapt Region...

(a) Under Input Coordinates, specify X Min and X Max as -0.129 and -0.116, respectively and Y Min and Y Max as 0, and 0.01, respectively. (b) Click Mark. FLUENT will report 288 cells marked for renement. (c) Click Manage... and in the Manage Adaption Registers panel, click Display. The chamber now appears in red (Figure 7).

c Fluent Inc. March 27, 2006

15

Projectile Moving Inside a Barrel

Adaption Markings (hexahedron-r0) (Time=0.0000e+00) Nov 18, 2005 FLUENT 6.2 (axi, coupled imp, dynamesh, unsteady)

Figure 7: Chamber Appears Red 4. Patch the chamber. Solve Initialize Patch...

(a) Under Variable, select Pressure. (b) Enter a Value of 3000 atm. (c) Under Registers To Patch, select hexahedron-r0. (d) Click Patch. (e) Similarly, patch Temperature at 2700 K. 16

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

5. Display contours of pressure, temperature, and density to verify the patching and conrm the density of 262 kg/m3 in the chamber. 6. Save the case and data les as, gun-6dof-real-init.cas.gz. Step 7: Mesh Motion Preview The mesh motion preview utility is useful for verifying that the mesh motion parameters yield the desired mesh motion. Because the initialized ow includes a patch, the projectile is driven by the patched pressure dierential. The preview is driven at a constant acceleration, based on that initial pressure force, because the ow is not computed during the preview. 1. Display the grid for the entire domain. 2. Specify the mesh motion. Solve Mesh Motion...

(a) Set the Time Step Size to 1e-6 seconds. (b) Set Number of Time Steps to 40 and click Preview. Study the mesh motion. Observe the chamber and the projectile. 3. Zoom in to see the chamber and the projectile and click Preview again. You can see how cells are being created, initially at a rate of one new layer for every thirty time steps. 4. Zoom in near the zone, p-out-destruct on the far right and click Preview and see how the cells are being destroyed. At the beginning of each new time step, messages from the UDF will appear in the TUI. UDF UDF UDF UDF message follows: message message: Flow time (sec) is .......... : 0.000157 message: Axial velocity (m/s) is ..... : 125.631042 17

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

UDF UDF UDF UDF UDF UDF UDF UDF

message message: message: message: message message: message: message

Change in axial position (mm) : 0.125631 Axial position (m): 0.009988 Net axial force (N) is ...... : 95416.828125 Axial force on base is 95448.804688 Axial force on nose is -31.982697

5. Exit FLUENT without saving. After verifying the correct behavior of the dynamic mesh, you can start again with the projectile at its starting point. Because the mesh has deformed and the projectile has moved, it is required to exit FLUENT without saving to revert to the original mesh position. Step 8: Postprocessing Setup 1. Start the 2D version of FLUENT and read the saved case and data les, projectile-6dof-real-init.cas.gz. File Read Case & Data... Note: If you have parallel licenses, you can also run parallel at this point, but you will have to recompile the fully parallelized UDF. This tutorial has been tested in parallel mode. 2. Display contours of velocity. Display Contours... (a) Under Contours Of, select Velocity and Velocity Magnitude. (b) Under Options, select Filled and deselect Global Range, Auto Range, and Clip to Range. (c) Increase the Levels to 50. (d) Set the value of Min to 0.001 and Max to 1000. (e) Click Display and close the panel. 3. Dene a surface monitor for absolute pressure (monitor-1). Solve Monitors Surface... (a) Increase Surface Monitors to 1. (b) Enable Plot, Print, and Write. (c) Under Every, select Time Step and click Dene.... i. In the Dene Surface Monitor panel, under Report Type, select Area-Weighted Average. ii. Under X Axis, select Flow Time.

18

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

iii. Increase Plot Window to 1. iv. Under Report Of, select Pressure and Absolute Pressure. v. Under Surfaces, select breech. vi. Click OK. 4. Dene a surface monitor for velocity magnitude (monitor-2). (a) Increase Surface Monitors to 2. (b) Enable Plot, Print, and Write. (c) Under Every, select Time Step and click Dene.... i. In the Dene Surface Monitor panel, under Report Type, select Area-Weighted Average. ii. Under X Axis, select Flow Time. iii. Increase Plot Window to 2. iv. Under Report Of, select Velocity and Velocity Magnitude. v. Under Surfaces, deselect breech and select w-proj-base. vi. Click OK. 5. Dene a surface monitor to track the x-position of the projectile (monitor-3). (a) Increase Surface Monitors to 3. (b) Enable Plot, Print, and Write. (c) Under Every, select Time Step and click Dene.... i. In the Dene Surface Monitor panel, under Report Type, select Vertex Average. ii. Under X Axis, select Flow Time. iii. Increase Plot Window to 3. iv. Under Report Of, select Grid and X-Coordinate. v. Under Surfaces, retain w-proj-base. vi. Click OK. (d) Click OK and close the panel. 6. Enable the logarithmic scale. Display Colormaps... (a) Enable Log Scale. (b) Under Number Format, set Type to general and Precision to 4. (c) Under Colormaps, ensure that Colormap Size is set to 50. (d) Click Apply and close the panel.

c Fluent Inc. March 27, 2006

19

Projectile Moving Inside a Barrel

7. Set the display in the graphic window. (a) Display velocity contours as described in Step 8-2. (b) Zoom in and adjust the view as shown in Figure 8.

Figure 8: Display for Animation (c) Save the view le. Display Views...

i. Under Save Name, enter view-projectile. ii. Under Actions, click Save and then click Write.... The Write Views panel opens iii. Under Views to Write, select view-projectile. 20

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

iv. Click OK and enter File Name as viewfile. 8. Set hardcopy parameters. File Hardcopy... (a) Under Format, enable TIFF. (b) Under Coloring, enable Color. (c) Under Resolution set the Width and Height to 800 and 600, respectively. (d) Click Apply and close the panel. 9. Set executable commands. Solve Execute Commands... (a) Increase Dened Commands to 1. (b) Increase Every to 10. (c) Under When, select Time Step. (d) Under Command, enter the TUI command: display contour velocity-magnitude 0.001 1000 (e) Enable On. (f) Increase Dened Commands to 2. (g) Increase Every to 10. (h) Under When, select Time Step. (i) Under Command, enter the TUI command: display hard-copy tiff-files/projectile-%t.tiff (j) Enable On and click OK. Note: Ensure that you create a subfolder named tiff-files in the working folder. The animation frames will be saved in this subfolder. Step 9: Solution 1. Set the solution parameters. Solve Controls Solution... (a) Set Courant Number to 100. (b) Under Discretization, select First Order Upwind for Flow. 2. Enable the plotting of residuals and disable all convergence checks. Solve Monitors Residual...

c Fluent Inc. March 27, 2006

21

Projectile Moving Inside a Barrel

(a) Enable Plot under Options. (b) Under Plotting, set Window to 4. (c) Under Plotting, change Iterations to 100. 3. Activate autosave option. File Write Autosave... (a) Set Autosave Cas File Frequency to 50. (b) Set Autosave Data File Frequency to 50. (c) Enable Overwrite Existing Files. (d) Set Maximum Number of Each File Type to 5. (e) Enter Filename as projectile-6dof-real.gz. projectile-6dof-real.gz is the basename for the le saves. 4. Save the case and data les, as projectile-6dof-real-init.cas.gz. This will overwrite the previous case and data les. 5. Solve for 960 time steps. Solve Iterate

22

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

(a) Set the Time Step Size to 1e-06 and the Number of Time Steps to 960. (b) Set the Maximum Iterations per Time Step to 25 and click Iterate. After about ve time steps, the pressure monitor becomes nearly at at the end of each time step. This indicates convergence within each time step. The residuals for axial velocity, continuity, and energy are dropping well within each time step. The radial velocity is less responsive because the ow is essentially onedimensional, causing the y-residual to be normalized by a small number. Note: The 960 time steps will take about 5.75 hours on a single processor with a clock speed of 2 GHz. At this time, you may choose to close this session of FLUENT, and resume from the instant the projectile leaves the muzzle. If you choose to exit, you will not be able to produce a complete animation. At the end of 960 time steps, the base of the projectile is just short of exiting the muzzle, i.e., just short of shot exit (uncorking). At this point, it is traveling at about 154 m/s, and the pressure inside the barrel is about 82 atmospheres. The ow time is near 0.96 milliseconds, and the maximum ow velocities are about 270 m/s. The contours of velocity are shown in Figure 9. 6. Solve until the projectile reaches the end of the muzzle. (a) Solve for 960 time steps, with 25 iterations per time step. Solve Iterate...

c Fluent Inc. March 27, 2006

23

Projectile Moving Inside a Barrel

Figure 9: Velocity Contours at the Instant of Uncorking (b) Save the current case and data les as projectile-6dof-real-960msec.cas.gz and projectile-6dof-real-960msec.dat.gz. 7. Solve until the projectile is placed well beyond the second muzzle brake. (a) In the Iterate panel, set the Time Step Size to 1e-07 seconds (smaller by a factor of ten). (b) In the Execute Commands panel, change Every from 10 to 100 for the two dened commands. (c) Set the Number of Time Steps to 6400 and click Iterate. This calculation will take about 43.5 hours on a single processor with a clock speed of 2 GHz. This will place the projectile well to the right of the second muzzle brake. The nal ow time will be about 1.60 msec. Note: If you do not want to run the iterations, you can read the nal case and data les, projectile-6dof-real-final.cas.gz and projectile-6dof-real-final.dat.gz and proceed with the postprocessing. Step 10: Postprocessing 1. Display the Velocity Magnitude (Figure 10). Display Contours... (a) Display velocity contours as described in Step 8-2. 2. Display the animation by entering the command animate *.tiff in the folder tiff-files.

24

c Fluent Inc. March 27, 2006

Projectile Moving Inside a Barrel

Figure 10: Velocity Contours at the End of the Simulation

c Fluent Inc. March 27, 2006

25