You are on page 1of 28

CHAPTER- I

INRODUCTION Modeling and simulation enables designers to test whether design specifications are met by using virtual rather than physical experiments. The use of virtual prototypes significantly shortens the design cycle and reduces the cost of design. It further provides the designer with immediate feedback on design decisions which, in turn, promises a more comprehensive exploration of design alternatives and a better performing final design. Simulation is particularly important for the design of multi-disciplinary systems in which components in different disciplines (mechanical, electrical, embedded control, etc.) are tightly coupled to achieve optimal system performance. This project surveys the current state of the art in modeling and simulation and examines to which extent current simulation technologies support the design of engineering systems. One of the most basic requirements for simulations in the context of design is that the modeling language be sufficiently expressive to model the non-linear, multi-disciplinary, hybrid continuous-discrete phenomena encountered in the design prototypes. Over the years, many modeling and simulation languages have been developed, but only a few of these languages are well suited for modeling of multi-disciplinary systems. The earliest simulation languages, based on CSSL (Continuous System Simulation Language), were procedural and provided a lowlevel description of a system in terms of ordinary differential equations. From these languages emerged two important developments: declarative (or equationbased) modeling, and object-oriented modeling. Current research further builds on these developments by moving towards component-based modeling and by providing support for hybrid (mixed continuous-discrete event) systems. Another requirement is that simulation

Department of Mechanical Engineering, GEC, Thrissur 1

models are easy to create and reuse. Creating high-fidelity simulation models is a complex activity that can be quite time-consuming. Object-oriented languages provide clear advantages with respect to model development, maintenance, and reuse. In addition, to take full advantage of simulation in the context of design, it is necessary to develop a modeling paradigm that is integrated with the design environment, and that provides a simple and intuitive interface that requires a minimum of analysis expertise. OBJECT ORIENTED PROGRAMMING (OOP) Object oriented programming is a technique for programming a paradigm for writing good programs for a set of problems. If the term object oriented programming language means anything it must mean a programming language that provides mechanisms that support the object oriented style of programming well. Over the years, the emphasis in the design of programs has shifted away from the design of procedures towards the organization of data. Among other things, this reflects an increase in the program size. A set of related procedures with the data they manipulate is often called a module. SINGLE-DOMAIN SIMULATION Simulation modeling defined for a single domain such as mechanical or electrical systems is a mature area, withseveral companies offering robust simulation packages.

HYDRAULIC AND THERMAL SYSTEMS Hydraulic and thermal systems are often modeled as interacting with each other and with mechanical components. The behavior of both thermal and hydraulic systems depends strongly on the geometry of the components and their physical configurations. As for mechanical systems, a tight integration with the 3D design environment is essential. From the review above, it is clear that many single-domain simulation environments are closely integrated with design tools.

Department of Mechanical Engineering, GEC, Thrissur 2

This trend is currently expanding towards the simulation and design of multidisciplinary systems in general.

VISUAL BASIC Visual Basic is a high level object oriented program developed by the Microsoft Corporation during the 90s. It is the advanced version of the BASIC language. It was mainly intended to make web and database applications. But recently, the astonishing changes brought in the VB helped programmers to use it in almost in every field.

NUMERICAL METHODS Many problems in engineering require solution of nonlinear algebraic equations In what follows we will show that the most popular numerical methods for solving such equations involve linearization which leads to repeatedly solving linear systems of the form Ax=b Solution of nonlinear equations always requires iteration . That is unlike linear systems where if solutions exist they can be obtained exactly with Gaussian elimination with nonlinear equations only approximate solutions are obtained. However in principle the approximations can be improved by increasing the number of iterations. Some of the important numerical methods are Newton Raphson method and Gauss Seidel iterative method.

Department of Mechanical Engineering, GEC, Thrissur 3

CHAPTER -II
PROJECT DEVELOPMENT NATURE OF WORK The projects consist of methods of solving using computational iterations such as in Newton Raphson and Gauss Seidel Method. Both the methods are applied on typical mathematical representations of problems underlying in mechanical engineering based. The projects are developed using Microsoft Visual Basic of Microsoft Visual Studio Professional Edition, one of the powerful object oriented programs using today. Each project consists of objects such as buttons, labels, textboxes etc. to manipulate or handle data more efficiently. The main advantages using this language are the freedom given to the developer to make more meaningful programs, their implementation, error detection etc. The methods are clearly being told one by one. In Newton Raphson Method , the following objects are being used in the development 1. A windows form to equip all controls or objects to manipulate data supplied by the user.

2. Buttons and labels to give more understanding about the whole program. 3. Timers to control the looping that takes place during iterations 4. Sub Procedures and Functions to do discrete amount of mathematical works alone. Etc.

Department of Mechanical Engineering, GEC, Thrissur 4

In Gauss Seidel the same objects used for the application development in Newton Raphson are also being used. The following are the main tools of the Visual Studio to develop standalone programs 1. A Code editor window , which helps to contain all the codes written according to the syntax 2. A Designer window, which primarily shows the form , where pic and place methods are used to populate the form with objects 3. A solution explorer to give the details about the current project 4. A properties window to show all the properties of each and every objects used on the application. 5. A Compiler which converts the codes written into executable application , if correct syntax is provided. Etc.

NEWTON RAPHSON METHOD EXAMPLE


A trunnion has to be cooled before it is shrink fitted into a steel hub.

Figure 2.1. A Trunnion and Steel Hub

Department of Mechanical Engineering, GEC, Thrissur 5

The equation that gives the temperature Tf to which the trunnion has to be cooled to obtain the desired contraction is given by F(Tf)= (-0.50598 * 10-10 x Tf3) + (0.38292 * 10-7 x Tf2) + (0.74363 x 10 -4 x Tf) + (0.88318 x 10-2)..........1

Use the Newton-Raphson method of finding roots of equations to find the temperature Tf to which the trunnion has to be cooled. Conduct three iterations to estimate the root of the above equation. Find the absolute relative approximate error at the end of iteration. SOLUTION The root of the equation can be found out from the equation given under At nth iteration the root is given by:

...........................................................2

Where,

= Guessed value

= Function value

= Differentiated function value

The absolute relative approximate error at the end of each iteration is given by:

Department of Mechanical Engineering, GEC, Thrissur 6

.........................................................................3

APPLICATION DEVELOPMENT IN VISUAL STUDIO The form is created and all the necessary objects or controls are placed on the form in a specific manner to give the user more easy to understand the application utilization. The following are the screen shots of the project work being developed on a Microsoft Windows 7 Operating system running 64-bit memory processor. System Info is given under: OS Name Version Other OS Description OS Manufacturer System Name System Manufacturer System Model System Type Processor Microsoft Windows 7 Ultimate 6.1.7600 Build 7600 Not Available Microsoft Corporation VISHNU R Dell Inc. Inspiron N5010 x64-based PC Intel(R) Core(TM) i3 CPU M 350 @ 2.27GHz, 2261 MHz, 2 Core(s), 4 Logical Processor(s) BIOS Version/Date Dell Inc. A04, 5/10/2010

The User interface is as follows

Department of Mechanical Engineering, GEC, Thrissur 7

Figure 2.2 VB Integrated Development Environment It consists of the following objects 1. 2. 3. 4. 5. 6. Buttons Group box Labels Textboxes Timer Windows Form

Along with useful functions, subs that are preserved or encapsulated in the code module

Department of Mechanical Engineering, GEC, Thrissur 8

The Code editor is as follows

Figure 2.3 Code Editor of Form Class

The module (iterative and error finder) code editor is as follows

Figure 2.4 Code Editor of Module

Department of Mechanical Engineering, GEC, Thrissur 9

PROGRAM CODE ********* DESIGNED AND DEVELOPED BY VISHNU.R ***********/' '****************NEWTON RAPHSON METHOD*********************' Option Explicit On Option Infer On Imports System.Windows.Forms Imports System.Math Public Class Form1 Public temp(), dftemp(), nrsolution() As Single Dim tempfirst As Decimal Public i As Short = 0 Public reqstring As String Private Sub btnNR_Click(ByVal sender As Object, ByVal e As

System.EventArgs) Handles btnNR.Click Try tempfirst = (-1 * (Val(txtAssume.Text))) reqstring = "" txtFinal.Text = "" Select Case txtLimit.TextLength Case Is > 0 ReDim temp(Val(txtLimit.Text) - 1) ReDim dftemp(Val(txtLimit.Text) - 1)

Department of Mechanical Engineering, GEC, Thrissur 10

ReDim nrsolution(Val(txtLimit.Text) - 1) Timer1.Enabled = True Case Else MessageBox.Show("Something has went wrong", "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Select Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try End Sub

Private

Sub

Timer1_Tick(ByVal

sender

As

Object,

ByVal

As

System.EventArgs) Handles Timer1.Tick Try Select Case i Case Is < Val(txtLimit.Text) Call timercall(tempfirst, i, temp, dftemp, reqstring, nrsolution) Case Is = Val(txtLimit.Text) Timer1.Enabled = False txtFinal.Text = txtFinal.Text & reqstring Form2.TextBox1.Text = Form2.TextBox1.Text & vbNewLine & vbNewLine & reqstring Form2.StartPosition = FormStartPosition.CenterScreen

Department of Mechanical Engineering, GEC, Thrissur 11

Form2.Show() reqstring = "" End Select If i > 0 Then If percenterror(i, nrsolution, tempfirst) < 0.1629 Then Timer1.Enabled = 0 txtFinal.Text = txtFinal.Text & reqstring Form2.TextBox1.Text = Form2.TextBox1.Text & vbNewLine & vbNewLine & reqstring Form2.StartPosition = FormStartPosition.CenterScreen Form2.Show() reqstring = "" End If End If i=i+1 Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) Form2.Enabled = 0 End Try End Sub

Private Sub btnClearall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearall.Click

Department of Mechanical Engineering, GEC, Thrissur 12

reqstring = "" Form2.TextBox1.Clear() Timer1.Stop() txtFinal.Clear() txtFinal.Enabled = 0 txtAssume.Clear() txtLimit.Clear() End Sub End Class

Department of Mechanical Engineering, GEC, Thrissur 13

CODE ENCAPSULATED IN MODULE '/********* DESIGNED AND DEVELOPED BY VISHNU R***********/' '****************NEWTON RAPHSONMETHOD*****************' Imports System.Math Module Iterartive_and_error_finder Public Opstring As String

Public Sub timercall(ByRef tempfirst As Integer, ByRef i As Integer, ByRef temp() As Single, ByRef dftemp() As Single _ , ByRef reqstring As String, ByRef nrsolution() As Single) Try temp(i) = (-0.50598 * 10 ^ (-10) * (tempfirst ^ 3)) + (0.38392 * (10 ^ (-7)) * (tempfirst ^ 2)) _ + (0.74363 * (10 ^ (-4)) * tempfirst) + (0.88318 * (10 ^ (-2))) dftemp(i) = (-1.51974 * (10 ^ (-10)) * (tempfirst ^ (-2))) + (0.76584 * (10 ^ (-7)) * tempfirst) _ + (0.74363 * (10 ^ (-4))) nrsolution(i) = tempfirst - (temp(i) / dftemp(i)) reqstring = CStr(reqstring & "**ITERATION NUMBER :" & (i + 1) & vbCrLf & "TEMPERATURE = " & CDec((temp(i))) & vbCrLf & "DIFFERENTIATED TEMPERATURE VALUE = " & CDec((dftemp(i))) _ & vbNewLine & "THE ESTIMATED ROOT IS = " &

CDec((nrsolution(i))) & _

Department of Mechanical Engineering, GEC, Thrissur 14

vbNewLine & "THE PERCENTAGE OF ERROR IS= " & percenterror(i, nrsolution, tempfirst) & "%" & vbNewLine & vbNewLine) tempfirst = nrsolution(i) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical)

End Try End Sub Public Function percenterror(ByRef i As Integer, ByRef nrsolution() As Single, ByVal tempfirst As Single) As Single Dim returnsoln As Single If i >= 0 Then returnsoln = ((nrsolution(i) - tempfirst) / nrsolution(i)) * 100 If returnsoln < 0 Then returnsoln = (-1 * returnsoln) Else returnsoln = returnsoln End If End If Return returnsoln End Function End Module

Department of Mechanical Engineering, GEC, Thrissur 15

GAUSS SEIDEL METHOD The relation between temperatures at three different points of a thermal system is shown under in the form of nonlinear equations. Our aim is to correct the equations based on a guessed value. This is being carried out with the help of iterations. This method is known as Gauss Seidel Method

Consider three nonlinear equations whose unknowns need to be found.

5Ta + 2Tb - Tc = 8 .................................................................4

Ta + 4Tb + Tc = 10 ................................................................5

Ta - Tb + 2Tc = 9 ................................................................6 It is rewritten as Ta = (8 - 2Tb + Tc)/5 .............................................................7 Tb = (10 - Ta Tc)/4 .............................................................8 Tc = (9 Ta + Tb)/2 ..............................................................9 The above mentioned equations are solved simultaneously using a computer program where a set of predetermined iterations are implemented. The iteration stops at the point where the required convergence is met.

APPLICATION DEVELOPMENT IN VISUAL STUDIO The form is created and all the necessary objects or controls are placed on the form in a specific manner to give the user more easy to understand the application utilization. The following are the screen shots of the project work being developed on a Microsoft Windows 7 Operating system running 64-bit memory processor.

Department of Mechanical Engineering, GEC, Thrissur 16

System Info is given under: OS Name Version Other OS Description OS Manufacturer System Name System Manufacturer System Model System Type Processor Microsoft Windows 7 Ultimate 6.1.7600 Build 7600 Not Available Microsoft Corporation VISHNU R Dell Inc. Inspiron N5010 x64-based PC Intel(R) Core(TM) i3 CPU M 350 @ 2.27GHz,

2261 MHz, 2 Core(s), 4 Logical Processor(s) BIOS Version/Date THE USER INTERFACE Dell Inc. A04, 5/10/2010

Figure 2.5 VB IDE for Gauss Seidel

Department of Mechanical Engineering, GEC, Thrissur 17

THE CODE EDITOR

Figure 2.6 VB Code editor of form class MODULE CODE EDITOR

Figure 2.7 VB Code editor of Module

Department of Mechanical Engineering, GEC, Thrissur 18

SOURCE CODE (FORM CLASS) '/**********DESIGNED AND DEVELOPED BY VISHNU.R*************/' '******************GAUSS SEIDEL METHOD***********************' Public Class Form1 Dim AssumTb, AssumTc As Single Dim finalText As String = "" Dim Ta() As Single = New Single() {} Dim Tb() As Single = New Single() {} Dim Tc() As Single = New Single() {} Dim i As Integer Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClick.Click Try ReDim Ta(CType(txtiter.Text, Single) - 1) ReDim Tb(CType(txtiter.Text, Single) - 1) ReDim Tc(CType(txtiter.Text, Single) - 1) AssumTb = CType(txtSecondTemp.Text, Single) AssumTc = CType(txtThirdTemp.Text, Single) Timer1.Enabled = 1 Timer1.Interval = 1 Form2.StartPosition = FormStartPosition.Manual Form2.Location = New Point(250, 250) Catch ex As Exception

Department of Mechanical Engineering, GEC, Thrissur 19

Timer1.Stop() MsgBox("ERROR DETECTED " & vbNewLine & ex.Message) Finally txtSecondTemp.TabStop = 1 End Try End Sub

Private Sub Timer1_Tick (ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Call TempSolver(AssumTb, AssumTc, Ta, Tb, Tc, i, finalText) If i >= 1 Then If Tc(i - 1) - Tc(i) <= 0.000001 AndAlso Ta(i - 1) - Ta(i) < 0.000001 _ AndAlso Tb(i - 1) - Tb(i) < 0.000001 Then Form2.Show() Form2.TextBox1.Text = Form2.TextBox1.Text & vbNewLine & vbNewLine & finalText Form2.TextBox1.Text = Form2.TextBox1.Text & vbNewLine & vbNewLine _ & " **The required condition is met at iteration number : " & (i + 1) & "**" Timer1.Stop () ElseIf i = (Val(txtiter.Text) - 1) Then Form2.Show () Form2.TextBox1.Text = finalText
Department of Mechanical Engineering, GEC, Thrissur 20

Timer1.Stop () End If End If i=i+1 End Sub

Private Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click txtFirstTemp.Clear() txtSecondTemp.Clear() txtThirdTemp.Clear() txtiter.Clear() txtSecondTemp.TabStop = 1 Form2.TextBox1.Clear () Form2.Close ()

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load txtSecondTemp.TabStop = 1 End Sub End Class

Department of Mechanical Engineering, GEC, Thrissur 21

CODE ENCAPSULATED (MODULE) '/**********DESIGNED AND DEVELOPED BY VISHNU.R*************/' '*****************GAUSS SEIDEL METHOD**********************' Module Module1 Public Sub TempSolver(ByRef AssumTb As Single, ByRef AssumTc As Single, ByRef Tempf() As Single, ByRef TempS() As Single As Single, ByRef i As Integer, ByRef finalString As String) TempS(i) = AssumTb TempT(i) = AssumTc Tempf(i) = ((8 - 2 * (TempS(i)) + TempT(i)) / 5) TempS(i) = ((10 - Tempf(i) - AssumTc) / 4) TempT(i) = ((9 - Tempf(i) + TempS(i)) / 2) AssumTb = TempS(i) AssumTc = TempT(i) finalString = finalString & "* The Tc value is " & TempT(i) & _ " and " & vbNewLine & " The Tb value is " & TempS(i) _ & vbNewLine & " The Ta value is " & Tempf(i) & vbNewLine & " The solution obtained at Iteration number : " _ & (i + 1) & vbNewLine & vbCrLf End Sub End Module , ByRef TempT()

Department of Mechanical Engineering, GEC, Thrissur 22

CHAPTER -III
RESULTS AND DISCUSSION NEWTON RAPHSON METHOD APPLICATION WITH INPUTS GIVEN

Figure 3.1 VB IDE with inputs given for Newton Raphson method APPLICATION DEVELOPED OUTPUTS

Figure 3.2 VB code compiled and executed

Department of Mechanical Engineering, GEC, Thrissur 23

OUTPUT WINDOW SEPERATED

Figure 3.3 VB Output Window of NR Method

OBTAINED OUTPUT Assumed value of temperature: 100oC Iterations required Iteration number: 1 After substitution Temperature= .001830018 Differentiated temperature= 0.0000667046 The estimated root of the equation= -127.437 The percentage of Approximate error = 21.5281%. Iteration number: 3 After substitution : 5 nos

Department of Mechanical Engineering, GEC, Thrissur 24

Temperature= -0.00001352756 Differentiated temperature= 0.00006448366 The estimated root of the equation= -128.7902 The percentage of Approximate error = 0.1628833% At the third iteration the predetermined condition i.e. the percentage of approximate error was being set to .169, and an instruction was given to stop looping if the error value comes below the predetermined value. The results are tabulated below Iteration 1 2 3 Temperature Diff.Temperature Root(oc) .001830018 0.0000667046 -127.4347 0.0001105676 0.00006463684 -128.7106 -0.00001352756 0.00006448366 -128.7902 Table 3.1 Tabulated Results of NR Method Error % 21.52841% 1.329029% 0.1628833%

GAUSS SEIDEL METHOD APPLICATION WITH INPUTS GIVEN

Figure 3.4 VB IDE with inputs given for Gauss Seidel Method

Department of Mechanical Engineering, GEC, Thrissur 25

OUTPUT WINDOW

Figure 3.5 VB Output Window of GS Method OBTAINED OUTPUTS The guessed value at point b= 0oC The guessed value at point c= 0oC The iterations given = 100 Required conditions were 1. Tc(i - 1) - Tc(i) <= 0.0001 (older - latest) 2. Ta(i - 1) - Ta(i) < 0.0001 3. Tb(i - 1) - Tb(i) < 0.0001 The satisfied solution was obtained at iteration no. 6 Iteration 1 2 3 4 5 6 Ta 0C Tb0C 1.6 2.1 1.71 0.885 2.0635 0.96225 2.004975 1.011412 1.996079 1.000176 2.00034 0.999403 Table 3.2 Tabulated Results of GS Method Tc 0C 4.75 4.0875 3.949375 4.003219 4.002048 3.999532

Department of Mechanical Engineering, GEC, Thrissur 26

CONCLUSIONS
This work depicts the state-of-the-art in modeling and simulation of engineering systems. Simulation is a very broad area that comprises many research issues that are not included in this work. I have limited my attention to issues that are particularly important with respect to system-level modeling in support of design. The modeling of mechatronic systems requires a language capable of describing physical phenomena in multiple energy domains, in continuous time as well as in discrete time. Recent advances in modeling have resulted in several modular, object-oriented languages that satisfy these requirements. To further simplify the modeling process and avoid unnecessary duplication of data entry, it is critical that the simulation environment be integrated with the design environment. In single-domain simulation

environments, this is already common practice. Current research is expanding this integration towards simulation of multi-disciplinary systems. Finally, due to the multi-disciplinary nature of mechatronic systems, the design requires a team of experts with different backgrounds. Systems modeling, therefore, must support collaborative modeling, including support for standardized languages, model management tools, and model abstraction tools. While using the Newton Raphson numerical method computationally, it has been found out the estimated root of the equation obtained obeying all prescribed conditions was -128.7902 0C and the iteration at which the convergence reached was at 3 While using the Gauss Seidel numerical method computationally, it has been found out the estimated values of the equation obtained obeying all prescribed conditions was Ta= 1.60C, Tb= 0.9994030C, Tc= 3.9995320C

Department of Mechanical Engineering, GEC, Thrissur 27

REFERENCES
[1] http://numericalmethods.eng.usf.edu

[2] Ascher, U. M. and Petzold, L. R., Computer Methods for Ordinary Differential Equations and Differential-Algebraic Equations. Philadelphia, Pennsylvania: SIAM, 1998.

[3] Design of Thermal Systems by Stoecker

[4] MODELING AND SIMULATION METHODS FOR DESIGN OF ENGINEERING SYSTEMS, Rajarishi Sinha , Vei-Chung Liang, Christiaan J.J. Paredis,Pradeep K. Khosla, Carnegie Mellon University, Pittsburgh, PA 15213, USA

Department of Mechanical Engineering, GEC, Thrissur 28

You might also like