eciv 201 computational methods for civil engineers
DESCRIPTION
ECIV 201 Computational Methods for Civil Engineers. Modeling, Computers, and Error Analysis. Richard P. Ray, Ph.D., P.E. Mathematical Modeling and Engineering Problem Solving. Requires understanding of engineering systems By observation and experiment Theoretical analysis and generalization - PowerPoint PPT PresentationTRANSCRIPT
USC
ECIV 201 Computational Methodsfor Civil Engineers
Richard P. Ray, Ph.D., P.E.
Modeling, Computers, and Error Analysis
USC
Mathematical Modeling and Engineering Problem Solving
• Requires understanding of engineering systems– By observation and experiment– Theoretical analysis and generalization
• Computers are great tools, however, without fundamental understanding of engineering problems, they will be useless.
USC
A mathematical model is represented as a functional relationship of the form
Dependent Independent Forcing
Variable = f Variables, Parameters,Functions
Dependent variable: Characteristic that usually reflects the state of the system
Independent variables: Dimensions such as time and space along which the systems behavior is being determined
Parameters: reflect the system’s properties or composition Forcing functions: external influences acting upon the system
USC
States that “the time rate change of momentum of a body is equal to the resulting force acting on it.”
The model is formulated asF = m a (1.2)
F = net force acting on the body (N)m = mass of the object (kg)a = its acceleration (m/s2)
Newton’s 2nd law of Motion
USC
Formulation of Newton’s 2nd law has several characteristics that are typical of mathematical models of the physical world: It describes a natural process or system in
mathematical terms It represents an idealization and simplification of
reality Finally, it yields reproducible results,
consequently, can be used for predictive purposes.
USC
Some mathematical models of physical phenomena may be much more complex.
Complex models may not be solved exactly or require more sophisticated mathematical techniques than simple algebra for their solution
Example, modeling of a falling parachutist:
USC
mcvmg
dtdv
cvFmgF
FFF
mF
dtdv
U
D
UD
vmcg
dtdv
This is a differential equation and is written in terms of the differential rate of change dv/dt of the variable that we are interested in predicting.
If the parachutist is initially at rest (v=0 at t=0), using calculus
FU
FD m
c
USC
tmcec
gmtv )/(1)(
Independent variable
Dependent variable
ParametersForcing function
USC
212,428 nodes, 189,078 brick elements and 1500 shell elements
Circular boundary to reduce reflections
USC
USC
Conservation Laws and Engineering
Conservation laws are the most important and fundamental laws that are used in engineering.
Change = Increases – Decreases (1.13) Change implies changes with time (transient).
If the change is nonexistent (steady-state), Eq. 1.13 becomes
Increases = Decreases
USC
For steady-state incompressible fluid flow in pipes:Flow in = Flow out
or100 + 80 = 120 + Flow4
Flow4 = 60
USC
Programming and Software Objective is how to use the computer as a tool
to obtain numerical solutions to a given engineering model. There are two ways in using computers: Use available software Write computer programs to extend the capabilities
of available software Engineers should not be tool limited, it is
important that they should be able to do both!
USC
Computer programs are set of instructions that direct the computer to perform a certain task.
To be able to perform engineering-oriented numerical calculations, you should be familiar with the following programming topics:
Simple variables (constants, variables, and type declaration)
Structured variables (data structure, arrays, and records) Mathematical formulas (assignment, priority rules, and
intrinsic functions) Input/Output Logical flow (sequence, selection, and repetition) Modular programming (functions and subroutines)
USC
Sub dft()Dim ytime(0 To 18000) As DoubleDim omega(0 To 8096) As DoubleDim yfreqr(0 To 8096) As DoubleDim yfreqi(0 To 8096) As DoubleDim t As Double, sumr As Double, sumi As DoubleDim sum As Double, omegadt As Double, omegat As Double, deltime As Double
Dim sigmaz(1 To 30, 1 To 30) As Single 'a two dimensional array of single-precision Dim rowstep, colstep As Integer 'steps used to point Dim i, j As Integer 'more counters
USC
Structured Programming
Structured programming is a set of rules that prescribe good style habits for programmers An organized, well structured code Easily sharable Easy to debug and test Requires shorter time to develop, test, and update
The key idea is that any numerical algorithm can be composed of using the three fundamental structures: Sequence, selection, and repetition
USC
Sequence. Computer code must be implemented one instruction at a time, unless you instruct otherwise. The structure can be expressed as a flowchart or pseudocode.
USC
Type Soil_Data 'Data for single soil layer Start_Depth As Single End_Depth As Single Dry_Weight As Single Sat_Weight As Single Percent_Fines As Single UCS_Class As String Description As StringEnd Type
Type Soil_Profile_Data 'Data for Soil Profile Description As String Start_Depth As Single End_Depth As Single NumSoils As Integer DepthGW As Single WeightGW As SingleEnd Type
USC
Sub ReadSoilProfile(j As Integer)'Read data put into spreadsheet at each profile Dim wksSoil As Worksheet Dim soilcolumn As Integer, soilrow, i As Integer Set wksSoil = Worksheets("Soil Profile") soilcolumn = j + 1 'Read Profile Information With SoilProfiles(j) .Description = wksSoil.Cells(6, soilcolumn) .Start_Depth = wksSoil.Cells(7, soilcolumn) .End_Depth = wksSoil.Cells(8, soilcolumn) .NumSoils = wksSoil.Cells(9, soilcolumn) .DepthGW = wksSoil.Cells(10, soilcolumn) .WeightGW = wksSoil.Cells(11, soilcolumn) End With End Sub
USC
Selection. Splits the program’s flow into branches based on outcome of a logical condition.
USC
Sub ifchecker()Dim i As Integer, j As Integer
i = 1j = 2
If i > j Then MsgBox ("I is bigger than J") Else MsgBox ("I is not bigger than J")End If
End Sub
USC
Repetition. A means to implement instructions repeatedly.
USC
Sub dataloops()' dataloops Macro' By R. Ray Dim sigmaz(1 To 30, 1 To 30) As Single 'a two dimensional array of single- 'precision Dim rowstep, colstep As Integer 'steps used to point to rows and columns Dim i, j As Integer MsgBox ("First write a row of xvalues“) For colstep = 1 To 30 Worksheets("Sheet1").Cells(1, colstep) = "xval " + CStr(colstep) 'write a row of ‘x values recall row-column notation Next colstep MsgBox ("Next, write a colum of y values") For rowstep = 1 To 30 Worksheets("Sheet1").Cells(rowstep, 1) = "yval " + CStr(rowstep) 'write a 'column of y values Next rowstep
USC
MsgBox ("Now, populate 2-D matrix, then write it out on sheet") For i = 1 To 30 'outside loop For j = 1 To 30 'inside loop sigmaz(i, j) = 10 * i + 2.2 * j 'yes this is a fully loaded matrix Next j Next i 'We have the matrix, now write it out somewhere (choice is arbitrary, 'we'll start at 2,2) For colstep = 1 To 30 'outside loop For rowstep = 1 To 30 'inside loop Worksheets("Sheet1").Cells(colstep + 1, rowstep + 1) = sigmaz(colstep, rowstep) Next rowstep Next colstep MsgBox ("Done") End Sub
USC
Modular Programming The computer programs can be divided into
subprograms, or modules, that can be developed and tested separately.
Modules should be as independent and self contained as possible.
Advantages to modular design are: It is easier to understand the underlying logic of smaller
modules They are easier to debug and test Facilitate program maintenance and modification Allow you to maintain your own library of modules for
later use
USC
EXCEL
Is a spreadsheet that allow the user to enter and perform calculations on rows and columns of data.
When any value on the sheet is changed, entire calculation is updated, therefore, spreadsheets are ideal for “what if?” sorts of analysis.
Excel has some built in numerical capabilities including equation solving, curve fitting and optimization.
It also includes VBA as a macro language that can be used to implement numerical calculations.
It has several visualization tools, such as graphs and three dimensional plots.
USC