Professional Documents
Culture Documents
ANSYS finite element analysis software enables engineers to perform the following
tasks:
1.1 In general, a finite-element solution may be broken into the following three
stages.
(ii) define element type and material/geometric properties, and (iii) mesh
The amount of detail required will depend on the dimensionality of the analysis,
i.e., 1D, 2D, axisymmetric, and 3D.
(translational and rotational), and finally solve the resulting set of equations.
1
(iii) Post processing: further processing and viewing of the results
In this stage one may wish to see (i) lists of nodal displacements, (ii) element
forces and moments, (iii) deflection plots, and (iv) stress contour diagrams or
temperature maps.
There are two methods to use ANSYS. The first is by means of the graphical user
interface or GUI. This method follows the conventions of popular Windows and X-
Windows based programs. The GUI method is exclusively used in this book. The second
is by means of command files. The command file approach has a steeper learning curve
for many, but it has the advantage that the entire analysis can be described in a small text
file, typically in less than 50 lines of commands. This approach enables easy model
modifications and minimal file space requirements. The ANSYS environment contains
two windows: the Main Window and an Output Window .Within the Main Window there
are five divisions (see Figure 1.1):
2
Figure 1.1 Main windows of ANSYS
(i) Utility Menu: The Utility Menu [A] contains functions that are available throughout
the ANSYS session, such as file controls, selections, graphic controls,
and parameters.
(ii) Input Line: The Input Line [B] shows program prompt messages and allows to type in
commands directly.
(iii) Toolbar: The Toolbar [C] contains push buttons that execute commonly used
ANSYS commands. More push buttons can be made available if desired.
(iv) Main Menu: The Main Menu [D] contains the primary ANSYS functions, organized
by preprocessor, solution, general postprocessor, and design
optimizer. It is from this menu that the vast majority of modeling
commands are issued.
(v) Graphics Windows: The Graphics Window [E] is where graphics are shown and
graphical picking can be made. It is here where the model in its various stages of
construction and the ensuing results from the analysis can be viewed.
The Output Window, shown in Figure 1.2, displays text output from the program, such as
listing of data, etc. It is usually positioned behind the Graphics Window and can be put to
the front if necessary.
3
Figure 1.2 Output window of ANSYS
It is a good practice to save the model at various stages during its creation. Very
often the stage in the modeling is reached where things have gone well and the model
ought to be saved at this point. In that way, if mistakes are made later on, it will be
possible to come back to this point. To save the model, from ANSYSUtilityMenu select,
File→Save as Jobname.db. The model will be saved in a file called Jobname.db, where
Jobname is the name that was specified in the Launcher when ANSYS was first started. It
is a good idea to save the job at different times throughout the building and analysis of
the model to backup the work in case of a system crash or other unforeseen problems.
Alternatively, select File → Save as. In response to the second option frame,shown in
Figure 1.3, is produced.B C
Select appropriate drive [A] and give the file a name [B]. Clicking [C] OK button
saves the model as a database with the name given.
Frequently there is a need to start up ANSYS and recall and continue a previous job.
There are two methods to do this:
(1) Using the Launcher. (i) In the ANSYS Launcher, select Interactive and specify the
previously defined jobname. (ii) When ANSYS is running, select Utility Menu:
File: Resume Jobname.db. This will restore as much of the database (geometry,
4
loads, solution, etc.) as was previously saved.
(2) Start ANSYS and select Utility Menu : File →Resume from and click on the job
from the list that appears. Figure 2.4 shows the resulting frame.
Select appropriate file fromthe list [A] and click [B]OK button to resume the analysis.
A large number of files are created when ANSYS is run. If ANSYS is started
without specifying a jobname, the name of all files created will be File.*, where the *
represents various extensions described below. If a jobname is specified, say Beam, then
the created files will all have the file prefix, Beam again with various extensions:
beam.db – database file (binary). This file stores the geometry, boundary conditions,
and any solutions. beam.dbb – backup of the database file (binary).
beam.err – error file (text). Listing of all error and warning messages.
beam.out – output of all ANSYS operations (text). This is what normally scrolls in
the output window during ANSYS session.
beam.log – log file or listing of ANSYS commands (text). Listing of all equivalent
ANSYS command line commands used during the current session.
5
Depending on the operations carried out, other files may have been written. These files
may contain, for example, results. It is important to know what to save when, for
instance, there is a need to clean up a directory or to move things from the /scratch
directory. If the GUI is always used, then only the .db file is required. This file stores the
geometry, boundary conditions, and any solutions. Once the ANSYS program has started,
and the job name has been specified, only the resume command has to be activated to
proceed from where the model was last left off. If, however, ANSYS command files are
planned to be used, then only command file and/or the log file have to be stored. The log
file contains a complete list of the ANSYS commands used to get the model to its current
stage. That file may be run as is, or edited and rerun as desired.
The "Preferences" dialog box allows you to choose the desired engineering
discipline for context filtering of menu choices. By default, menu choices for all
disciplines are shown, with non-applicable choices "dimmed" based on a set of element
types in your model. If you prefer not to see the dimmed choices at all, you should turn
on filtering. For example, turning on structural filtering completely suppresses all
thermal, electromagnetic, and fluid menu topics.
Choose Main Menu> Preferences. The Preferences for GUI Filtering dialog box
appears
6
2.2.2. Define Material Properties
3. Type the text EXX in the EX field (for Young's modulus), and .3 for PRXY.
Click on OK. This sets Young's modulus to the parameter specified above.
Material Model Number 1 appears in the Material Models Defined window on the
left.
4. Choose menu path Material> Exit to remove the Define Material Model
Behavior dialog box.
1. ANSYSMainMenu→Preprocessor→Real Constants
3. Menu as shown
(1) Click Add/Edit/Delete button to open the Real Constants window and click
Add…button.
(2) Then the Element Type for Real Constants window opens. Click OK button.
(3) The Element Type for Real Constants window vanishes and the Real
Constants Set Number 1. for PLANE82 window appears
3. Click on Apply.
7
1. Choose menu path Main Menu> Preprocessor> Modeling> Create> Lines>
Lines> Straight Line. The Create Straight Line picking menu appears.
2. Click once on keypoints 1 and 2 to create a line between keypoints 1 and 2.
3. Click on OK.
1. Choose menu path Main Menu> Preprocessor> Meshing> Size Cntrls> Lines>
Picked Lines. The Element Size on Picked Lines picking menu appears.
2. select the line, then press ENTER.
3. Click on OK in the picking menu. The Element Sizes on Picked Lines dialog box
appears.
1. Choose menu path Main Menu> Preprocessor> Meshing> Mesh> lines> all
lines. The Mesh lines picking box appears.
2. Click on Pick All.
1. Choose menu path Main Menu> Solution> Define Loads> Apply> Structural>
Displacement> on keypoints. The Apply U,ROT on Nodes picking menu
appears.
2. Click on Pick All. The Apply U,ROT on Nodes dialog box appears.
4. Click on OK.
1. Choose menu path Main Menu> Solution> Define Loads> Apply> Structural>
Pressure> on lines or on beams or on areas. The Apply PRES on Nodes
picking menu appears.
2. Click on Pick All. The Apply PRES on lines dialog box appears.
8
2.2.10. Exit ANSYS
3. Click on OK.
AIM:
To do the analysis of a cantilever beam using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for cantilever beam is given for analysis, there by the
corresponding shear force and bending moment diagram is to be drafted.
PROCEDURE:
1. PREFERENCES
9
(i) Main menu → preferences → structural
2. PRE PROCESSOR – Define the Problem
(i) Main menu → Pre Processor → Element type → add / edit /delete→ add
→ beam 2D elastic 3 → ok → close
(ii) Main menu → Pre Processor → real constants → add /edit /delete→ add
→ ok → AREA = 100, IZZ = 104/12, HEIGHT=10.
(iii) Main menu → Pre Processor → Material props → Material models →
structural →linear → elastic → isotropic → Ex = 210000, PRXY=.3→
close
(iv) Main menu → Pre Processor → modeling → create → key points → In
active CS→ kp1=0,0. apply→ kp2=100,0 → OK
(v) Main menu → Pre Processor → modeling → create →Lines→line→
straight lines→ click kp1, kp2→ press ok
(vi) Main menu → Pre Processor → meshing → size cntrls → manual size →
lines → all lines → no of element divisions → 200
(vii) Main menu → Pre Processor → meshing → mesh → lines → click the
line → press ok
(viii) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on key points → select kp1→ click ok → all
DOF=0.
(ix) Main menu → Pre Processor →loads → define loads→ Apply →
structural→ force / moment → select kp2 → ok→ Fy= -1000.
3. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
4. GENERAL POST PROCESSOR – Obtaining results
(i) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(ii) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
10
(iii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(iv) General Post Processor→ element table → define table → add→ by
sequence number → node I SMISC 2 → apply
→ node J SMISC 8 → OK
(v) General Post Processor→ Plot results →Contour plot→ Line Elem Res
→ node I SMISC 2 → node J SMISC 8 → OK
(vi) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
(vii) General Post Processor→ Plot results → Contour plot→ Line Elem Res
→ node I SMISC 6 →node J SMISC 12 → OK
(viii) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
11
RESULT:
Thus the shear stress and bending moment diagrams of cantilever beam was drawn
and analysis is carried out using ANSYS software.
AIM:
To do the analysis of a simply supported beam using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for simply supported beam is given for analysis, there by
the corresponding shear force and bending moment diagram is to be drafted.
12
PROCEDURE:
2. PREFERENCES
13
(x) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xi) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xii) General Post Processor→ element table → define table → add→ by
sequence number → node I SMISC 2 → apply
→ node J SMISC 8 → OK
(xiii) General Post Processor→ Plot results →Contour plot→ Line Elem Res
→ node I SMISC 2 → node J SMISC 8 → OK
(xiv) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
(xv) General Post Processor→ Plot results → Contour plot→ Line Elem Res
→ node I SMISC 6 →node J SMISC 12 → OK
(xvi) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
14
RESULT:
Thus the shear force and bending moment diagram for simply supported beam was
drawn and analysis is carried out using ANSYS software.
AIM:
To do the analysis of a fixed beam using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for fixed beam is given for analysis, there by the
corresponding shear force and bending moment diagram is to be drafted.
PROCEDURE:
3. PREFERENCES
15
2. PRE PROCESSOR – Define the Problem
(i) Main menu → Pre Processor → Element type → add / edit /delete→ add
→ beam 2D elastic 3 → ok → close
(ii) Main menu → Pre Processor → real constants → add /edit /delete→ add
→ ok → AREA = 100, IZZ = 104/12, HEIGHT=10.
(iii) Main menu → Pre Processor → Material props → Material models →
structural →linear → elastic → isotropic → Ex = 210000, PRXY=.3→
close
(iv) Main menu → Pre Processor → modeling → create → key points → In
active CS→ kp1=0,0. Apply→kp2=250,0 Apply → kp3=500,0 → OK
(v) Main menu → Pre Processor → modeling → create →Lines →line→
straight lines→ click kp1, kp2→ press apply→ click kp2, kp3→ press ok
(vi) Main menu → Pre Processor → meshing → size cntrls → manual size →
lines → all lines → no of element divisions → 200
(vii) Main menu → Pre Processor → meshing → mesh → lines → click the
line → press ok
(viii) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on key points → select kp1 and select kp3→
click ok → all DOF=0.
(ix) Main menu → Pre Processor →loads → define loads→ Apply →
structural→ force / moment → select kp2 → ok→ Fy= -1000.
7. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
8. GENERAL POST PROCESSOR – Obtaining results
16
(iv) General Post Processor→ element table → define table → add→ by
sequence number → node I SMISC 2 → apply
→ node J SMISC 8 → OK
(v) General Post Processor→ Plot results →Contour plot→ Line Elem Res
→ node I SMISC 2 → node J SMISC 8 → OK
(vi) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
(vii) General Post Processor→ Plot results → Contour plot→ Line Elem Res
→ node I SMISC 6 →node J SMISC 12 → OK
(viii) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
17
RESULT:
Thus the shear force and bending moment diagram for fixed beam was drawn and
analysis is carried out using ANSYS software.
AIM:
To do the analysis of a rectangular plate with hole using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for rectangular plate with hole is given for analysis, there
by the stress and deflection is calculated below.
PROCEDURE:
4. PREFERENCES
18
2. PRE PROCESSOR – Define the Problem
(i) Main menu → Pre Processor → Element type → add / edit /delete→ add
→ solid quad 4 node 42 → options select Element behavior(k3) =plane
strs w/thk →ok→close
(ii) Main menu → Pre Processor → real constants → add /edit /delete→ add
→ ok → THK=10.
(iii) Main menu → Pre Processor → Material props → Material models →
structural →linear → elastic → isotropic → Ex = 210000, PRXY=.3→
close
(iv) Main menu → Pre Processor → modeling → create → areas →
rectangle→By2corner→wp x=0, wp y=0 width=200 height=100→ok
(v) Main menu → Pre Processor → modeling → create → areas →
circle→solid circle→wp x=100, wp y=50 Radius=20 →ok
(vi) Main menu → Pre Processor → modeling → operate → Booleans →
subtract → Areas →click rectangle first → ok → select circle → ok
(vii) Main menu → Pre Processor → meshing → size cntrls → manual size →
areas → All areas → element edge length=5
(viii) Main menu → Pre Processor → meshing → mesh → areas → free →
click the area → press ok
(ix) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on line → select lest side line → click ok →
all DOF=0.
(x) Main menu → Pre Processor →loads → define loads→ Apply →
structural→ pressure → on line → select right side line → ok→
value=-100.
9. SOLUTION – Solve the problem
(ix) Solution → solve → current LS→ ok
10. GENERAL POST PROCESSOR – Obtaining results
19
(i) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok Note
DMX=.117485_______
(ii) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(iii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(iv) General Post Processor→ Plot results →Contour plot→ Nodal solu →
DOF solution → displacement vector sum → OK
(v) Utility Menu → Plot controls → animate → Deformed results → DOF
resuls → vsum
(vi) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
(vii) General Post Processor→ Plot results → Contour plot→ Nodal solu →
stress → Von mises stress → OK
SMX=350.63
SMN=27.927
(viii) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
20
RESULT:
Thus stresses in a plate with a hole was Analysed and results were plotted using
ANSYS.
AIM:
To do the analysis of a rectangular bracket using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for rectangular bracket is given for analysis, there by the
stress and deflection is calculated below.
21
PROCEDURE:
1. PREFERENCES
22
(xi) Main menu → Pre Processor → modeling → create →lines → Line fillet
→select right and bottom lines click ok → Fillet radius =7
(xii) Main menu → Pre Processor → modeling → create → areas → Arbitrary
→ by lines → click arc and two lines → ok
(xiii) Main menu → Pre Processor → modeling → operate → Booleans → add
→ Areas →pick all
(xiv) Main menu → Pre Processor → modeling → operate → Booleans →
subtract → Areas →click rectangle first → ok → select two circles → ok
(xv) Main menu → Pre Processor → meshing → size cntrls → manual size →
areas → All areas → element edge length=4
(xvi) Main menu → Pre Processor → meshing → mesh → areas → free →
click the area → press ok
(xvii) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on line → select bottom circle 4 lines →
click ok → all DOF=0.
(xviii) Main menu → Pre Processor →loads → define loads→ Apply →
structural→ pressure → on line → select top two cicle line → ok→
Value=-100.
3. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
4. GENERAL POST PROCESSOR – Obtaining results
23
(v) Utility Menu → Plot controls → animate → Deformed results → DOF
resuls → vsum
(vi) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
(vii) General Post Processor→ Plot results → Contour plot→ Nodal solu →
stress → Von mises stress → OK
SMX=
SMN=
(viii) Utility Menu → Plot controls → write meta file → invert black/ white →
save the image in local drives
24
RESULT:
Thus the stresses in rectangular bracket were studied and result was plotted.
AIM:
To do the analysis of a hollow cylinder using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for hollow cylinder is given for analysis, there by the stress
and deflection is calculated below.
PRXY=0.3
25
PROCEDURE:
1. PREFERENCES
26
(x) Utility Menu → select → entities →By location →Y coordinates =50 →
ok
(xi) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on nodes → select pick all → UY=0 →
click ok.
(xii) Utility Menu → select → entities →By location →Y coordinates → select
all → cancel
(xiii) Main menu → Pre Processor →loads → define loads→ Apply →
structural→ force/moment → on keypoint → select top corner point →
Fy=100
(xiv) Main menu → Pre Processor →loads → define loads→ Apply →
structural→ force/moment → on keypoint → select bottom corner point
→ Fy=-100
3. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
4. GENERAL POST PROCESSOR – Obtaining results
27
SMN=
(vii) Utility Menu → Plot controls → write meta file → invert black/ white→
save the image in local drives
RESULT:
Thus the stresses in axi-symmetric component were studied and result was plotted.
AIM:
To do the dynamic analysis of a cantilever beam using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for cantilever beam is given for analysis, there by the
corresponding mode shape is to be drafted.
PROCEDURE:
1. PREFERENCES
28
(ii) Main menu → Pre Processor → real constants → add /edit /delete→ add
→ ok → AREA = 100, IZZ = 104/12, HEIGHT=10.
(iii) Main menu → Pre Processor → Material props → Material models →
structural →linear → elastic → isotropic → Ex = 210000, PRXY=.3→
close
(iv) Main menu → Pre Processor → Material props → Material models
→ structural →density=7.85*(10e-10) → close
(v) Main menu → Pre Processor → modeling → create → key points → In
active CS→ kp1=0, 0. apply→ kp2=100,0 → OK
(vi) Main menu → Pre Processor → modeling → create →Lines → line→
straight lines→ click kp1, kp2→ press ok
(vii) Main menu → Pre Processor → meshing → size cntrls → manual size →
lines → all lines → no of element divisions → 200
(viii) Main menu → Pre Processor → meshing → mesh → lines → click the
line → press ok
(ix) Solution → analysis type → new analysis → modal → ok
(x) Solution → analysis type → analysis options → sub space → No of
modes to extract =5 → No of modes to expand=5 →ok → ok
(xi) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on key points → select kp1→ click ok → all
DOF=0.
3. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
4. GENERAL POST PROCESSOR – Obtaining results
29
(iv) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(v) General Post Processor→ read results → next set
(vi) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(vii) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(viii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(ix) General Post Processor→ read results → next set
(x) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(xi) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xiii) General Post Processor→ read results → next set
(xiv) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(xv) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xvi) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xvii) General Post Processor→ read results → next set
(xviii) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
30
(xix) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xx) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
RESULT: Thus the modal analysis has been done on cantilever beam and mode
shapes have been obtained.
AIM:
To do the dynamic analysis of a cantilever beam using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for simply supported beam is given for analysis, there by
the corresponding mode shape is to be drafted.
PROCEDURE:
2. PREFERENCES
31
(ii) Main menu → Pre Processor → real constants → add /edit /delete→ add
→ ok → AREA = 100, IZZ = 104/12, HEIGHT=10.
(iii) Main menu → Pre Processor → Material props → Material models →
structural →linear → elastic → isotropic → Ex = 210000, PRXY=.3→
close
(iv) Main menu → Pre Processor → Material props → Material models
→ structural →density=7.85*(10e-10) → close
(v) Main menu → Pre Processor → modeling → create → key points → In
active CS→ kp1=0,0. apply→ kp2=100,0 → OK
(vi) Main menu → Pre Processor → modeling → create →Lines → line→
straight lines→ click kp1, kp2→ press ok
(vii) Main menu → Pre Processor → meshing → size cntrls → manual size →
lines → all lines → no of element divisions → 200
(viii) Main menu → Pre Processor → meshing → mesh → lines → click the
line → press ok
(ix) Solution → analysis type → new analysis → modal → ok
(x) Solution → analysis type → analysis options → sub space → No of
modes to extract =5 → No of modes to expand=5 →ok → ok
(xi) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on key points → select kp1 and kp2→ click
ok → Ux,Uy=0.
5. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
6. GENERAL POST PROCESSOR – Obtaining results
32
(iv) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(v) General Post Processor→ read results → next set
(vi) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(vii) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(viii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(ix) General Post Processor→ read results → next set
(x) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(xi) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xiii) General Post Processor→ read results → next set
(xiv) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(xv) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xvi) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xvii) General Post Processor→ read results → next set
(xviii) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
33
(xix) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xx) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
RESULT: Thus the modal analysis has been done on simply supported beam and mode
shapes have been obtained.
AIM:
To do the dynamic analysis of a fixed beam using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for fixed beam is given for analysis, there by the
corresponding mode shape is to be drafted.
PROCEDURE:
1. PREFERENCES
34
(ii) Main menu → Pre Processor → real constants → add /edit /delete→ add
→ ok → AREA = 100, IZZ = 104/12, HEIGHT=10.
(iii) Main menu → Pre Processor → Material props → Material models →
structural →linear → elastic → isotropic → Ex = 210000, PRXY=.3→
close
(iv) Main menu → Pre Processor → Material props → Material models →
structural →density=7.85*(10e-10) → close
(v) Main menu → Pre Processor → modeling → create → key points → In
active CS→ kp1=0, 0. apply→ kp2=500,0 → OK
(vi) Main menu → Pre Processor → modeling → create →Lines → line→
straight lines→ click kp1, kp2→ press ok
(vii) Main menu → Pre Processor → meshing → size cntrls → manual size →
lines → all lines → no of element divisions → 200
(viii) Main menu → Pre Processor → meshing → mesh → lines → click the
line → press ok
(ix) Solution → analysis type → new analysis → modal → ok
(x) Solution → analysis type → analysis options → sub space → No of
modes to extract =5 → No of modes to expand=5 →ok → ok
(xi) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on key points → select kp1 and kp2→ click
ok → All DOF=0.
7. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
8. GENERAL POST PROCESSOR – Obtaining results
35
(iv) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(v) General Post Processor→ read results → next set
(vi) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(vii) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(viii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(ix) General Post Processor→ read results → next set
(x) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(xi) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xiii) General Post Processor→ read results → next set
(xiv) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(xv) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xvi) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xvii) General Post Processor→ read results → next set
(xviii) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
36
(xix) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xx) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
RESULT: Thus the modal analysis has been done on fixed beam and mode shapes
have been obtained.
AIM:
To do the dynamic analysis of a rectangular component using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for rectangular component is given for analysis, there by
the corresponding mode shape is to be drafted.
PROCEDURE:
1. PREFERENCES
37
(i) Main menu → Pre Processor → Element type → add / edit /delete→ add
→ solid quad 4 node 42 → options select Element behavior(k3) =plane
strs w/thk →ok →close
(ii) Main menu → Pre Processor → real constants → add /edit /delete→ add
→ ok → THK=10.
(iii) Main menu → Pre Processor → Material props → Material models →
structural →linear → elastic → isotropic → Ex = 210000, PRXY=.3→
close
(iv) Main menu → Pre Processor → Material props → Material models →
structural →density=7.85*(10e-10) → close
(v) Main menu → Pre Processor → modeling → create → areas →
rectangle→By2corner→wp x=0, wp y=0 width=200 height=100→ok
(vi) Main menu → Pre Processor → meshing → size cntrls → manual size →
areas → all areas → element edge length=1
(vii) Main menu → Pre Processor → meshing → mesh → areas → free →
click the areas → press ok
(viii) Solution → analysis type → new analysis → modal → ok
(ix) Solution → analysis type → analysis options → sub space → No of
modes to extract =5 → No of modes to expand=5 →ok → ok
(x) Main menu → Pre Processor →loads → define loads → apply →
structural → displacement → on key points → select kp1 and kp2→ click
ok → All DOF=0.
9. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
10. GENERAL POST PROCESSOR – Obtaining results
38
(iv) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(v) General Post Processor→ read results → next set
(vi) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(vii) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(viii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(ix) General Post Processor→ read results → next set
(x) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(xi) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xiii) General Post Processor→ read results → next set
(xiv) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
(xv) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xvi) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(xvii) General Post Processor→ read results → next set
(xviii) General Post Processor→ plot results → deformed shape → def +
undeformed → click ok
Note DMX=_______
39
(xix) Utility Menu → Plot controls → animate → Deformed shape → time
delay .2
(xx) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
40
Result:
Thus the modal Analysis of 2D component was done and results were plotted.
EXP 10 HARMONIC ANALYSIS OF A CANTILEVER
BEAM
AIM:
To do the harmonic analysis of a cantilever beam using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for cantilever beam is given for analysis, there by the
corresponding harmonic response is to be drafted.
PROCEDURE:
1. PREFERENCES
41
(i) Main menu → preferences → structural
2. PRE PROCESSOR – Define the Problem
(i) Main menu → Pre Processor → Element type → add / edit /delete→ add
→ beam 2D elastic 3 → ok → close
(ii) Main menu → Pre Processor → real constants → add /edit /delete→ add
→ ok → AREA = 100, IZZ = 104/12, HEIGHT=10.
(iii) Main menu → Pre Processor → Material props → Material models →
structural →linear → elastic → isotropic → Ex = 210000, PRXY=.3→
close
(iv) Main menu → Pre Processor → Material props → Material models
→ structural →density=7.85*(10e-10) → close
(v) Main menu → Pre Processor → modeling → create → key points → In
active CS→ kp1=0, 0. apply→ kp2=100,0 → OK
(vi) Main menu → Pre Processor → modeling → create →Lines → line→
straight lines→ click kp1, kp2→ press ok
(vii) Main menu → Pre Processor → meshing → size cntrls → manual size →
lines → all lines → no of element divisions → 200
(viii) Main menu → Pre Processor → meshing → mesh → lines → click the
line → press ok
(ix) Solution → analysis type → new analysis → harmonic→ ok
(x) Solution → Analysis Type → Analysis Options → select the Full Solution
method, the Real + imaginary DOF printout format → ok →ok
(xi) Solution → Define Loads → Apply → Structural → Displacement → On
Nodes → select kp1 → give real part =0, img part =0
(xii) Main menu → Pre Processor → loads → define loads → apply →
Force/Moment → On Nodes → select kp2 → real part = --100 img part =0
(xiii) Solution → Load Step Opts → Time/Frequency → Freq and Substps →
specify a frequency range of 0 - 100Hz, 100 substeps → select steped
method → ok
3. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
42
4. GENERAL POST PROCESSOR – Obtaining results
(i) TimeHist Postpro → Variable Viewer →Add (the green '+' sign in the
upper left corner) → Nodal Solution → DOF Solution → Y-Component
of displacement → select node 2 → click the 'List' button → close → click
the 'Plot' button, (2 buttons to the left of 'Add')
To get a better view of the response, view the log scale of UY
Utility Menu → PlotCtrls → Style → Graphs → Modify Axis → change
the Y-axis scale to 'Logarithmic' →Utility Menu > Plot > Replot
(ii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
43
Result:
Thus the Harmonic Analysis of given cantilever beam was done and results were
plotted
EXP 11 CONDUCTIVE HEAT TRANSFER ANALYSIS
OF 2D COMPONENT
AIM:
To do the thermal analysis of a square component using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for square component is given for analysis there by the
corresponding temperature distribution is to be drafted.
PROCEDURE:
1. PREFERENCES
44
(i) Main menu → Pre Processor → Element type → add / edit /delete→ add
→ solid quad 4 node 55 → →ok →close
(ii) Main menu → Pre Processor → Material props → Material models →
thermal → conductivity → isotropic → Kxx=58.5 → close
(iii) Main menu → Pre Processor → modeling → create → areas →
rectangle→By2corner→wp x=0, wp y=0 width=1 height=1→ok
(iv) Main menu → Pre Processor → meshing → size cntrls → manual size →
areas → all areas → element edge length=.05
(v) Main menu → Pre Processor → meshing → mesh → areas → free →
click the areas → press ok
(vi) Main menu → Pre Processor →loads → define loads → apply → thermal
→ temperature → on line→ select left line, bottom line and right side line
→ click ok → temp=100
(vii) Main menu → Pre Processor →loads → define loads → apply → thermal
→ temperature → on line→ select top line → click ok → temp=500
3. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
4. GENERAL POST PROCESSOR – Obtaining results
(i) General Post Processor→ plot results → contour plot → nodal solu →
DOF solution → nodal temperature
(ii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(iii) General Post Processor→ plot results → contour plot → nodal solu →
thermal gradient → thermal gradient vector sum
(iv) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(v) General Post Processor→ plot results → contour plot → nodal solu →
thermal flux → thermal flux vector sum
(vi) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
45
RESULT:
Thus the conductive heat Transfer analysis of component was done and results were
plotted.
AIM:
To do the thermal analysis of a square component using ANSYS software.
PROBLEM DESCRIPTION:
Here the specification for square component is given for analysis there by the
corresponding temperature distribution is to be drafted.
PROCEDURE:
1. PREFERENCES
46
(i) Main menu → Pre Processor → Element type → add / edit /delete→ add
→ solid quad 4 node 55 → →ok →close
(ii) Main menu → Pre Processor → Material props → Material models →
thermal → conductivity → isotropic → Kxx=58.5 → close
(iii) Main menu → Pre Processor → modeling → create → areas →
rectangle→By2corner→wp x=0, wp y=0 width=1 height=1→ok
(iv) Main menu → Pre Processor → meshing → size cntrls → manual size →
areas → all areas → element edge length=.05
(v) Main menu → Pre Processor → meshing → mesh → areas → free →
click the areas → press ok
(vi) Main menu → Pre Processor →loads → define loads → apply → thermal
→ temperature → on line→ select left line → click ok → temp=100
(vii) Main menu → Pre Processor →loads → define loads → apply → thermal
→ temperature → on line→ select top line → click ok → temp=500
(viii) Main menu → Pre Processor →loads → define loads → apply → thermal
→ Convection → on line→ select left line → click ok → film coefficient
=10 and bulk temperature=100
(ix) Main menu → Pre Processor →loads → define loads → apply → thermal
→ Convection → on line→ select bottom line → click ok → film
coefficient =0
3. SOLUTION – Solve the problem
(i) Solution → solve → current LS→ ok
4. GENERAL POST PROCESSOR – Obtaining results
(i) General Post Processor→ plot results → contour plot → nodal solu →
DOF solution → nodal temperature
(ii) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(iii) General Post Processor→ plot results → contour plot → nodal solu →
thermal gradient → thermal gradient vector sum
47
(iv) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
(v) General Post Processor→ plot results → contour plot → nodal solu →
thermal flux → thermal flux vector sum
(vi) Utility Menu→ Plot controls → write meta file → invert black/ white→
save the image in local drives
48
RESULT:
Thus the convective heat Transfer analysis of component was done and results were
plotted.
INTRODUCTION TO
C++ PROGRAMMING
49
OVERVIEW OF C++ PROGRAMMING
KEY FEATURES
50
A TASTE OF C
Like in every other programming language learning book we use the Hello world
program to introduce you to C.
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
Enter this code into your text editor or IDE, and save it as "hello.c".
Then, presuming you are using GCC, type gcc -o hello hello.c. This tells
gcc to compile your hello.c program into a form the machine can execute. The '-o hello'
tells it to call the compiled program 'hello'.
If you have entered this correctly, you should now see a file called hello. This file
is the binary version of your program, and when run should display "Hello, world!"
Line-by-Line Explanation
Line 1 tells the C compiler to find a file called stdio.h and add the contents of that
file to this program. In C, you often have to pull in extra optional components when you
need them. stdio.h contains descriptions of standard input/output functions; in other
words, stuff you can use to send messages to a user, or to read input from a user.
Line 3 is something you'll find in every C program. Every program has a main
function. Generally, the main function is where a program begins. However, one C
51
program can be scattered across multiple files, so you won't always find a main function
in every file. The int at the beginning means that main will return an integer to whatever
made it run when it is finished.
Line 4 is the statement that actually sends the message to the screen. printf is a
function that is declared in the file stdio.h - which is why you had to #include that at the
start of the program. \n is an escape sequence which adds a new line at the end of the
printed text.
Line 5 will return zero (which is the integer referred to on line 3) to the operating
system. When a program runs successfully its return value is zero (GCC4 complains if it
doesn't when compiling). A non-zero value is returned to indicate a warning or error.
Line 7 is there because it is (at least on UNIX) considered good practice to end a
file with a new line. In gcc using the -Wall -pedantic -ansi options, if the file does
not end with a new line this message is displayed: "warning: no newline at end of file".
As a basic example, you are writing code to print out the first 5 squares of numbers, then
the first 5 cubes, then the next 5 squares again. We could write it like this:
52
for(i=1; i <= 5; i++)
{
printf("%d ", i*i);
}
for(i=1; i <= 5; i++)
{
printf("%d ", i*i*i);
}
for(i=1; i <= 5; i++)
{
printf("%d ", i*i);
}
We have to write the same loop twice. We may want to somehow put this code in
a separate place and simply jump to this code when we want to use it.
FILE FUNCTIONS
fopen
Declaration:
Opens the filename pointed to by filename. The mode argument may be one of the
following constant strings:
53
r+ read and write text mode
w+ read and write text mode (truncates file to zero length or creates new file)
a+ read and write text mode (opens or creates file and sets file pointer to the end-of-file)
fclose
Declaration:
getchar
Declaration:
int getchar(void);
Gets a character (an unsigned char) from stdin.
54
if
Syntax:
or
for
Syntax:
Examples:
55
for(loop=0;loop<1000;loop++)
printf("%i\n",loop);
#include
The #include directive allows external header files to be processed by the compiler.
Syntax:
#include <header-file>
or
#include "source-file"
When enclosing the file with < and >, then the implementation searches the
known header directories for the file (which is implementation-defined) and processes it.
When enclosed with double quotation marks, then the entire contents of the source-file
are replaced at this point. The searching manner for the file is implementation-specific.
Examples:
#include <stdio.h>
#include "my_header.h"
List of Keywords
56
default goto sizeof volatile
do if static while
57
SIMULATION OF AIR CONDITIONING SYSTEM WITH CONDENSER
TEMPERATURE AND EVAPORATOR TEMPERATURES AS INPUT
TO GET COP USING C++.
Aim:
To write and execute the “C” program for Simulation of R & AC mechanical
system.
Algorithm:
Input Program:
Start a new program
Get the necessary inputs and store it into “RACINPUT.txt”.
Save and execute the program.
Stop the Program
Output Program:
Start a new program
Get the Necessary inputs from “RACINPUT.txt”.
Calculate COP= (T1/ (T1-T2)) and RC= (W*COP).
Save and execute the program
Store the outputs to “RACOUT.txt”
Stop the program.
Programs:
Input Program:
#include <stdio.h>
#include <conio.h>
void main()
{
int i,n;
float T1,T2,W;
FILE *fp1;
clrscr();
fp1=fopen("RACINPUT.txt","w");
printf("\n\nEnter the value of N:");
scanf("%d",&n);
fprintf(fp1,"\n\t%d",n);
for(i=1;i<=n;i++)
{
printf("\n Enter the condensor Temparature:");
scanf("%f",&T1);
printf("\n Enter the Evaporator Temparature:");
scanf("%f",&T2);
58
printf("\n Enter the Work done:");
scanf("%f",&W);
fprintf(fp1,"\n\n\t%f\t",T1);
fprintf(fp1,"%f\t",T2);
fprintf(fp1,"%f",W);
}
getch();
}
Output Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
float T1,T2,W,COP,RC;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("RACINPUT.txt","r");
fp2=fopen("RACOUT.txt","w");
fprintf(fp2,"\n\t\t----------------------------------------");
fprintf(fp2,"\n\t\t SIMULATION OF R & AC MECHANICAL OUTPUTS");
fprintf(fp2,"\n\t\t----------------------------------------");
fscanf(fp1,"%d",&n);
fprintf(fp2,"\n\t\t\t No of Observations:=%d\n",n);
for (i=1;i<=n;i++)
{
fscanf(fp1,"%f%f%f", &T1,&T2,&W);
COP=(T1/(T1-T2));
RC=(W*COP);
fprintf(fp2,"\n\t\t Observations%d",i);
fprintf(fp2,"\n\n\t\tCOP=\t%f",COP);
fprintf(fp2,"\n\t\tRC=\t%f",RC);
}
fprintf(fp2,"\n\t\t----------------END---------------------");
getch();
}
Contents of File:
RACOUT.txt
------------------------------------------------------------------------
SIMULATION OF R & AC MECHANICAL OUTPUTS
------------------------------------------------------------------------
No of Observations=5
59
Observations1
COP= 1.111
RC= 38.888
Observations2
COP= 1.111
RC= 22.222
Observations3
COP= 1.174
RC= 35.294
Observations4
COP= 1.066
RC= 15.000
Observations5
COP= 1.200
RC= 66.000
----------------END---------------------
RACINPUT.txt
5
1500 1350 35
500 350 20
1000 150 30
800 350 15
1800 1300 55
Result:
Thus the given program was executed successfully and their corresponding inputs
and outputs are stored.
60
Aim:
To write and execute the “C” program for Simulation of Hydraulic/ Pneumatic
cylinder.
Algorithm:
Input Program:
Start a new program
Get the necessary inputs and store it into “HPINPUT.txt”.
Save and execute the program.
Stop the Program
Output Program:
Start a new program.
Get the Necessary inputs from “HPINPUT.txt”.
Calculate pressure, velocity, area, horse power using formulae.
Save and execute the program.
Store the outputs to “HPOUTPUT.txt”
Stop the program.
Programs:
Input Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
float F,R,D;
FILE *fp1;
clrscr();
fp1=fopen("HPINPUT.txt","w");
printf("Enter the Sequence of time");
scanf("%d",&n);
fprintf(fp1,"\t%d\n",n);
for (i=1;i<=n;i++)
{
printf("Enter the Force:");
scanf("%f",&F);
fprintf(fp1,"\n\t%f",F);
printf("Enter the Radius:");
scanf("%f",&R);
fprintf(fp1,"\t%f",R);
61
printf("Enter the Discharge:");
scanf("%f",&D);
fprintf(fp1,"\t%f\n",D);
}
}
Output Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
float F,R,D,A,P,V,HP;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("HPINPUT.txt","r");
fp2=fopen("HPOUTPUT.txt","w");
fscanf(fp1,"%d",&n);
fprintf(fp2,"\n\t----------------------------------------------------------------------------\
n");
fprintf(fp2,"\tSIMULATION OF HYDRAULIC / PNEUMATIC CYLINDER\
n");
fprintf(fp2,"\t-------------------------------------------------------------------------------\
n");
for (i=1;i<=n;i++)
{
fscanf(fp1,"%f%f%f", &F,&R,&D);
A= (3.14*R*R);
P= (F/A);
V= (D/A);
HP= (F*V);
fprintf(fp2,"\n\t\tObservations:%.d",i);
fprintf(fp2,"\n\t\tPRESSURE=%0.2f\n",P);
fprintf(fp2,"\t\tAREA=%0.2f",A);
fprintf(fp2,"\t\tVELOCITY=%0.2f\n",V);
fprintf(fp2,"\t\tHP=%0.2f\n",HP);
}
fprintf(fp2,"\n\t-------------------END---------------------");
}
Contents of File:
HPOUTPUT.txt
-----------------------------------------------------------------------------
SIMULATION OF HYDRAULIC / PNEUMATIC CYLINDER
----------------------------------------------------------------------------
62
Observations:1
PRESSURE=1.59
AREA=314.00 VELOCITY=0.16
HP=79.62
Observations:2
PRESSURE=0.85
AREA=706.50 VELOCITY=0.07
HP=39.07
Observations:3
PRESSURE=1.33
AREA=452.16 VELOCITY=0.15
HP=90.23
Observations:4
PRESSURE=1.21
AREA=379.94 VELOCITY=0.17
HP=78.70
Observations:5
PRESSURE=0.35
AREA=1133.54 VELOCITY=0.04
HP=15.88
-------------------------------------END--------------------------------------
HPINPUT.txt
5
500.000000 10.000000 50.000000
600.000000 15.000000 46.000000
600.000000 12.000000 68.000000
460.000000 11.000000 65.000000
400.000000 19.000000 45.000000
Result:
Thus the given program was executed successfully and their corresponding inputs
and outputs are stored.
SIMULATION OF CAM AND FOLLOWER MECHANISM USING C++.
63
Aim:
To write and execute the “C” program for Simulation of CAM & FOLLOWER
mechanism.
Algorithm:
Input Program:
Start a new program
Get the necessary inputs and store it into “CAMINPUT.txt”.
Save and execute the program.
Stop the Program
Output Program:
Start a new program
Get the Necessary inputs from “CAMINPUT.txt”.
Calculate the Angular velocity and Follower rise using formulae.
Save and execute the program
Store the outputs to “CAMPUTPUT.txt”
Stop the program.
Programs:
Input Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
float N,Rc,Rb;
FILE *fp1;
clrscr();
fp1=fopen("CAMINPUT.txt","w");
printf("Enter the Sequence of time:");
scanf("%d",&n);
fprintf(fp1,"%d\n",n);
for (i=1;i<=n;i++)
{
printf("Enter the RPM:");
scanf("%f",&N);
fprintf(fp1,"%0.2f\t",N);
printf("Enter the CAM Radius:");
scanf("%f",&Rc);
fprintf(fp1,"%0.2f\t",Rc);
64
printf("Enter the BASE Radius:");
scanf("%f",&Rb);
fprintf(fp1,"%0.2f\n",Rb);
}
}
Output Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
float N,Rc,Rb,H,W;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("CAMINPUT.txt","r");
fp2=fopen("CAMOUTPUT.txt","w");
fscanf(fp1,"%d",&n);
fprintf(fp2,"\n\t---------------------------------------------------------------------\n");
fprintf(fp2,"\tSIMULATION OF CAM & FOLLOWER MECHANISM\n");
fprintf(fp2,"\t------------------------------------------------------------------------\n");
for (i=1;i<=n;i++)
{
fscanf(fp1,"%f%f%f", &N,&Rc,&Rb);
W=((2*3.14*N)/60);
H=Rc-Rb;
fprintf(fp2,"\n\t\tObservations:%.d",i);
fprintf(fp2,"\n\t\tAngular Velocity =%0.2f\n",W);
fprintf(fp2,"\t\tFollower Rise =\t%0.2f\n",H);
}
fprintf(fp2,"\n\t-------------------------------END---------------------------------");
}
Content of File:
CAMINPUT.txt
5
600.00 15.00 10.00
400.00 14.00 12.00
800.00 20.00 15.00
1500.00 24.00 20.00
560.00 20.00 14.00
CAMOUTPUT.txt
-----------------------------------------------------------------------
SIMULATION OF CAM & FOLLOWER MECHANISM
65
----------------------------------------------------------------------
Observations:1
Angular Velocity =62.80
Follower Rise = 5.00
Observations:2
Angular Velocity =41.87
Follower Rise = 2.00
Observations:3
Angular Velocity =83.73
Follower Rise = 5.00
Observations:4
Angular Velocity =157.00
Follower Rise = 4.00
Observations:5
Angular Velocity =58.61
Follower Rise = 6.00
-------------------------------END--------------------------------
Result:
Thus the given program was executed successfully and their corresponding inputs
and outputs are stored.
66