Professional Documents
Culture Documents
7 Matlab
7 Matlab
Programming Language: C
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
main()
{
float hfg5,tc1,tc2,te,cp,hg1,h2,hg2,hf3,hf4,hg4,hfg4,cop,copi,eff,x;
printf("\nEnter the temperature of compressor exit<Celsius> "); scanf("%f",&tc1);
printf("\nEnter the temperature of condenser<Celsius> "); scanf("%f",&tc2);
printf("\nEnter temperature of evaporator<Celcius> "); scanf("%f",&te);
printf("\nEnter the value of cp "); scanf("%f",&cp);
printf("\nEnter the value of Enthalpy at 1(hg1) "); scanf("%f",&hg1);
}
Input Parameters:
Temperature of compressor
Temperature of condenser
Temperature of evaporator
Cp
Value of Enthalpy at 1, 2`, 3, 4
Output Parameters:
Result:
Thus simulation of vapour compression refrigerator has been done using C.
Viva voice
1.What are the types of loops does MATLAB provides?
Matlab provides loops like
• While Loop
• For Loop
• Nested Loops
2.Explain what is Simulink?
EX.NO:16
DATE:
Aim
The model for a mass attached to a spring with a linear damping force.
Problem Statement:
x + 2 !nx + !n2 x = 0:
In the above, !n represents the undamped natural frequency, and is the viscous
damping ratio. For the purposes of this example, we will assume the under damped case
(<1). The solution to this equation is:
PROGRAM
Programming Language: C
%The while loop in the zeta initialization section prevents %certain values for zeta
from being entered, since such %values would crash the program.
if (zeta(zi)>=1 j zeta(zi)<0)
fprintf(’Zeta must be between 0 and 1!’); zeta(zi)=12;
end
end
end
%
%Now, having !n and , the !d values can be found.
%
for i=1:3 wd(i)=wn*sqrt(1-zeta(i)^2);
end
%
%Solving for the response. Note the use of the array %multiplication command (.*) in the
expression for x(t). %This command is necessary, else the program gives a
%multiplication error.
phi=atan2(wd(j)*x0,v0+zeta(j)*wn*x0); x(j,:)=a*exp(-zeta(j)*wn*t).*sin(wd(j)*t+phi);
end
%
%Now, the program plots the results in a subplot format.
%
subplot(3,1,1)
plot(t,x(1,:))
title([’Response for zeta=’,num2str(zeta(1))]) ylabel(’Response x’)
grid subplot(3,1,2) plot(t,x(2,:))
title([’Response for zeta=’, num2str(zeta(2))]) ylabel(’Response x’)
grid subplot(3,1,3) plot(t,x(3,:))
title([’Response for zeta=’, num2str(zeta(3))]) ylabel(’Response x’)
xlabel(’Time, seconds’) grid
Result:
The model for a mass attached to a spring with a linear damping force has been done using C.
Viva voice
1. What is the damping force?
Damping Coefficient. When a damped oscillator is subject to a damping force which
is linearly dependent upon the velocity, such as viscous damping, the oscillation will
have exponential decay terms which depend upon a damping coefficient.
DATE:
AIM:
PROCEDURE:
2) Type the name of the new database as two_columns and click OK.
Step 2 - Create the geometry of the columns using the information from the problem
statement.
1) Under the Geometry tab, click on Point and select XYZ.
2)Input the following point coordinates and click Apply after each point: [0 0 0], [0 10 0],
and [0 -10 0]. There are no units in Patran, and therefore it is important to stay consistent in
units.
4) With Auto Execute checked, click on Point 1 then Point 2, and Point 1 then Point 3.
2) Input Material as the Material Name and then select Input Properties .
Step 4- Create a 1D surface physical property and apply the isotropic material to the
model.
1) Click on Rod under the 1D Properties section.
2) Input Top_Column as the Property Set Name and then click on Input Properties.
3)Click on Select Material and select Material. Enter 1.5 as the Area. Click OK.
4) Click on Select Application Region and then click on the Select Members box. Screen pick
the top curve. Click Add, OK then Apply.
5) Repeat the above steps for the bottom curve except input Bottom_Column as the Property
Set Name and enter 2 as the area.
Step 5 - Create boundary conditions: Constrain all degrees of freedom along the bottom of the
structure.
1) Under the Load/BCs tab, select Displacement Constraint.
2) Input fixed_end as the New Set Name and then click on Input Data.
3) Input <0,0,0> for Translations (to prevent any translational movement), but leave the
Rotations blank, < > (to NOT prevent any rotational movement). Click OK.
4) Click on Select Application Region and then click on the Select Geometry Entries box.
Screen select Click Point 3. Click Add, OK then Apply.
4) Click on Select Application Region and then click on the Select Geometry Entries box.
Screen select Point 2. Click Add, OK, then Apply.
2)Set the Number of Elements to 1, and with Auto Execute checked, select each curve.
4) Click on the Select Curve List box. Screen click both curves using the Shift key. Click
Apply.
5) Set Action to Equivalence and click Apply (This will eliminate duplicate nodes at the
intersection of the two curves).
Step 9 - Attach results file, then create fringe and deformation plots. Record maximum displacement
and stresses.
1) Click on XDB under the Access Results submenu. .
RESULT:
To calculate the stresses at point A and point B by a 5000 lb load is placed at the
center of the radius and center of the thickness of a crane hook with a rectangular cross
section: b = 0.75 in. and h = 4 in.
PROCEDURE:
2) Type the name of the new database as hook then click OK.
2)IType [0 0 0] for the Point Coordinates list, then uncheck Auto Execute and then click
Apply. If Auto Execute is checked, then once the Points are entered it will automatically
create the point after hitting enter, without the need to click Apply. Becareful if Auto Execute
is on and Apply is clicked then a duplicate point will be created.
4)Now change the Object to Curve then choose the Starting Point List as Point 1 and Ending
Point List as Point 2 then click Apply.
2) Now change the Object to Surface. The surface will be created using 2 curves, so set the
Method to Curve and then choose Curve 2 as the Starting Curve List and choose Curve 1 as
the Ending Curve List. Since Auto Execute is on it will automatically generate the surface
without the need to click Apply.
2) Change the Translation Vector to <0 0 0.75> and for Surface List choose Surface 1. The
Translation Vector shows that the surface is being extruded 0.75 in the Z direction.
2) For the Orgin type [-2 0 0], change the Point on Axis 3 to[-2 0 1] and change the Point on
Plane 1-3 to [1 0 0].
2) Choose Coord 1 for the Refer. Coordinate Frame, type Coord 1.3 for the Axis. This means
that it is using coordinate 1 with rotation in the 3rd axis. Finally change the Total Angle to -
180.0.
3)Choose the Surface Solid 1.5. Solid 1.5 means that the surface is in solid 1 with a surface
number 5.
2)For the Height List type 0.75, the Radius List type 2.0 and for the Thickness List type 0.0.
3) For the Base Center Point List type [-6 0 0], for the Axis List type Coord 0.3, and then
click Apply.
2) Click on the Add icon, which is to merge 2 solids together. The second icon subtract one
solid from another and the thrid icon keeps the intersection of 2 solids.
3) For the Solid List Choose Solid 1:3 then click Apply.
4) Now let change the view to smooth shaded by Right Clicking, choose ViewPort Display
and choose Smooth Shaded.
RESULT:
Hence the stresses at point A and point B of crane hook is analyzed by MSC Nastran