Why computer programming
description
Transcript of Why computer programming
![Page 1: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/1.jpg)
CIV1900
Dr Sam Clarke
Introduction
Civil Engineering Skills
Computer programming
![Page 2: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/2.jpg)
Have you programmed before?
A. Yes (C++, Java)B. Yes (Html, CSS)C. Yes (Fortran,
Matlab)D. No
A. B. C. D.
25% 25%25%25%
![Page 3: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/3.jpg)
There are 5 weeks of material that combine a short lecture (~ 30 mins), with a 2 hour computer class and a short quiz
Today’s intro lecture & variables
There will be two sessions (Wks10 & 11) that explain how to accomplish particular programming tasks
The final session is more about computer graphics and introduces the programming assessment.
How this fits in...
![Page 4: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/4.jpg)
1. Final quiz is worth 10% (wk12)Portfolio elements (printed graphics & code) 10%
2. 4 online tests (weeks 8-11) Unlimited attempts, 70% to pass.Each worth 1.25%You will not be allowed to proceed to the next Quiz without successful completion
Assessment
![Page 5: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/5.jpg)
What is Computer Programming?
![Page 6: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/6.jpg)
Why engineers need to program
Computer modelling and its importance for engineering problems
How to write an algorithm to solve an engineering task
Contents for Lecture 1
![Page 7: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/7.jpg)
Why engineers need to program
Computer modelling and its importance for engineering problems
How to write an algorithm to solve an engineering task
Contents for Lecture 1
![Page 8: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/8.jpg)
What is an Algorithm?
A. A step-by-step procedure for calculations
B. A random computer process
C. The music of algaeD. The principle of
how a computer works
A. B. C. D.
25% 25%25%25%
![Page 9: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/9.jpg)
What is an Algorithm?
How a computer executes a process
OrderInstructionsRules
![Page 10: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/10.jpg)
On famous physicist Richard Feynman’s blackboard at the time of his death was the following statement:
“What I cannot create I do not understand.”
![Page 11: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/11.jpg)
Hence, an ability to program or, at the very least, an ability to understand how programs work, is today a vital engineering skill that greatly enhances employability.
![Page 12: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/12.jpg)
Simple Physics
We will have a look at this later…
![Page 13: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/13.jpg)
Beam Stress
![Page 14: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/14.jpg)
Finite Element Analysis
You will learn about this in 3rd year
![Page 15: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/15.jpg)
Fluid Dynamics
You will learn about this in 3rd year
![Page 16: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/16.jpg)
Groundwater flow
![Page 17: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/17.jpg)
Many of the examples we have just seen involve computer models of engineering structures.
Modelling is a very important application of programming.
Programming can be used to streamline a series of repeated tasks.(such as routine design)
Uses
![Page 18: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/18.jpg)
Uses
Geotechnics
![Page 19: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/19.jpg)
Uses
Resistance
Force
Angle 1
Angle 2
![Page 20: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/20.jpg)
Uses
Can you imagine how long this would take by hand!!
![Page 21: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/21.jpg)
Uses
![Page 22: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/22.jpg)
Uses
Angle 1: 0-90° in 0.1° increments (900)Angle 2: 0-90° in 0.1° increments (900)810000 combinations...
![Page 23: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/23.jpg)
Uses
Each pixel represents a calculationAutomated using computer programming
![Page 24: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/24.jpg)
We can only formulate a model for a process if we have some understanding of the relevant physics.
This will be a simplification of reality because we are unable to include all possible factors – we try to include those that our engineering judgement deem to be the most relevant.
This is closure – we choose to close out some aspects of reality to focus on others.
Limitations
![Page 25: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/25.jpg)
Verification is our checking to see that our model contains the relevant physics and that we solve the equations that we formulate for the processes in an appropriate way.
Validation is our checking that the outputs from our model match our expectations of the behaviour of the real system.
Verification & Validation
![Page 26: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/26.jpg)
In order to determine the specification for a new bridge you need to estimate the probable 200 year discharge on a river.
The traditional method to do this involves finding the largest event in a year and fitting a statistical distribution to these annual maxima.
The raw data that your firm have been given are daily discharge maxima.
Example
![Page 27: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/27.jpg)
Data
![Page 28: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/28.jpg)
By hand, the procedure that we would follow to construct the annual maxima is something like:
(1) Scroll down through the data finding the first and last values in a particular year;
(2) Sort these data in descending order of discharge and isolate the top value (the annual maximum);
(3) Write this value into a column in a new file with the year in an adjacent column;
(4) Move on to the next year and repeat.
![Page 29: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/29.jpg)
All programming involves is the writing of an algorithm such as that just given into a language that the computer can process and understand.
The particular language we will be using is that for the Matlab software.
Other computer languages tend to work in similar basic ways.
Programming
![Page 30: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/30.jpg)
Known as loops
For…. loops
While… loops
For… loops repeat a set of statements a set number of times.
While… loops keep repeating WHILE some condition holds.
We will cover this more in Week 11
Repeating Stuff
![Page 31: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/31.jpg)
For our example from the discharge dataset, imagine we have 32 years of data, with either 365 or 366 days in a year.
![Page 32: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/32.jpg)
Illustrating algorithms with flow diagrams
Process
Decision
Data
![Page 33: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/33.jpg)
Loop through
NumDays
Currentvalue
Is this > Maximum?
Set Maximum to 0
No
Leap year data
Is current year a leap year?
NumDays = 366
Yes
No
NumDays = 365
Yes
![Page 34: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/34.jpg)
Set Maximum to this new value
On completion of the inner loop write out Maximum for this year
All of the statements that we have written are themselves embedded in a For loop where the counter runs from 1 to 32, meaning that the annual maximum for each year is written out.
![Page 35: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/35.jpg)
Over the next few weeks you will:
• Be taught how to use Matlab and gain an experience in writing Matlab code.
• Be given an engineering problem which you will have to solve using Matlab
Thus, by week 12 you should be able to code up an algorithm yourself.
![Page 36: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/36.jpg)
=
![Page 37: Why computer programming](https://reader034.fdocuments.in/reader034/viewer/2022051515/5538462a4a79590a7f8b46cb/html5/thumbnails/37.jpg)
Next Week…
Guest lecture on Civil Engineering design
Peer Assessment period