computational physics with java - covenant...
TRANSCRIPT
![Page 1: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/1.jpg)
C O M P U T A T I O N A L P H Y S I C SW I T H
JAVA
S E G U N E M M A N U E L ( A B O D E )
F R I D A Y 6 T H , O C T O B E R 2 0 1 6
![Page 2: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/2.jpg)
O U T L I N E
• OV E RV I E W O F C O M P U TAT I O N A L P H YS I C S
• TO O LS O F C O M P U TAT I O N A L P H YS I C S
• I N T RO D U C T I O N TO J AVA
• C O MP O N E N T S O F J AVA
• H A N D S - O N
![Page 3: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/3.jpg)
WHAT IS COMPUTATIONAL PHYSICS?
• Computational Physics may be broadly defined as 'the
science of using computers to assist in the solution of
physical problems, and to further physics research'.
• Computational physics is a tool for solving complex
numerical problems in physics
![Page 4: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/4.jpg)
WHAT IS COMPUTATIONAL PHYSICS?
• Both experimental and theoretical physics are incomplete
without the option to compute whenever it is neccessary.
• The goal of computational physics is not to replace theory
or experiment, but to enhance our understanding of
physical processes
![Page 5: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/5.jpg)
WHAT IS COMPUTATIONAL PHYSICS?
• Computational physics bridges both theory and experiment physics
![Page 6: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/6.jpg)
MULTIDISCIPLINARY NATURE OF COMPUTATIONAL PHYSICS
![Page 7: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/7.jpg)
APPLICATION IN PHYSICS
• Large scale quantum mechanical calculations in nuclear, atomic, molecular and
condensed matter physics
• Large scale calculations in such fields as hydrodynamics, astrophysics, plasma
physics, meteorology and geophysics
• Simulation and modelling of complex physical systems such as those that occur
in condensed matter physics, medical physics and industrial applications
• Computer algebra; development and applications etc
![Page 8: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/8.jpg)
WHY DO WE NEED COMPUTATIONAL PHYSICS?
• We need computational physics when:
we cannot solve problems analytically
we have too much data to process
• Many, if not the most, problems in contemporary physics
could never be solved without computers
![Page 9: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/9.jpg)
O U T L I N E
• OV E RV I E W O F C O M P U TAT I O N A L P H YS I C S
• TO O LS O F C O M P U TAT I O N A L P H YS I C S
• I N T RO D U C T I O N TO J AVA
• C O MP O N E N T S O F J AVA
• H A N D S - O N
![Page 10: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/10.jpg)
TOOLS OF COMPUTATIONAL PHYSICS
•Mathematical software packages such as
MATHEMATICA, MAPLE or MATLAB etc
•Programming Languages such as JAVA, C#,
PYTHON, FORTRAN, C, C++ etc
![Page 11: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/11.jpg)
ADVANTAGES OF MATHEMATICAL SOFT WARE PACK AGES
•They facilitate the very rapid coding up of
numerical problems
•Good for small and medium projects
![Page 12: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/12.jpg)
DISADVANTAGES OF MATHEMATICAL SOFT WARE PACK AGES
•They produce executable code which is
interpreted, rather than compiled.
•They are not suitable for full-blown research
projects, since the code which they produce
generally runs far too slowly
![Page 13: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/13.jpg)
PROGRAMMING L ANGUAGES
•Interpreted Languages e.g BASIC, Perl, PHP,
VBScript, Power Shell etc
•Compiled Languages e.g Fortran, Java, C#,
C++, Python etc.
![Page 14: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/14.jpg)
INTERPRETED VS COMPILED L ANGUAGES
• Programming with compiled languages gives more control, power, flexibility for
numerically and logically intensive tasks
• Compiled code is translated directly from a high-level language into machine
code instructions, which, by definition, are platform dependent.
• Interpreted code is translated from a high-level language into a set of meta-
code instructions which are platform independent.
• Interpreted code is nowhere near as efficient, in terms of computer resource
utilization, as compiled code
![Page 15: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/15.jpg)
APPROACHING PHYSICS PROBLEMS
![Page 16: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/16.jpg)
O U T L I N E
• OV E RV I E W O F C O M P U TAT I O N A L P H YS I C S
• TO O LS O F C O M P U TAT I O N A L P H YS I C S
• I N T RO D U C T I O N TO J AVA
• C O MP O N E N T S O F J AVA
• H A N D S - O N
![Page 17: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/17.jpg)
INTRODUCTION TO JAVA
• Java was originally developed by james
gosling at sun microsystems in 1995
• Acquired by oracle corporation 2010
![Page 18: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/18.jpg)
INTRODUCTION TO JAVA
• The Java programming language is an excellent choice for learning, teaching, or doing
computational physics.
• It is a well-designed, modern programming language that is simultaneously easy to learn and
very powerful.
• It includes a range of features tailored for scientific computing, including features for handling
vectors, inverting and diagonalizing matrices, performing Fourier transforms, making graphs, and
creating 3D graphics.
![Page 19: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/19.jpg)
FEATURES OF JAVA
![Page 20: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/20.jpg)
FEATURES OF JAVA
• Java SE (Java Standard Edition)
• Java EE (Java Enterprise Edition)
• Java ME (Java Micro Edition)
![Page 21: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/21.jpg)
PRIMARY GOALS OFJAVA
• Provides an easy-to-use language by:
• Avoiding many pitfalls of other languages
• Being object-oriented
• Enabling users to create streamlined and clear code
• Enables users to run more than one thread of activity
• Loads classes dynamically; that is, at the time they areactually needed
• Supports changing programs dynamically duringruntime by loading classes from disparate sources
• Furnishes better security
![Page 22: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/22.jpg)
PLACES WHERE JAVA IS USED
• Java is implemented over a number of
places in modern world.
• It is implemented as:
➢ Standalone Application
➢ Web Application
➢ Enterprise Application
➢ Mobile Application
➢ Games
➢ Smart Card
➢ Embedded System
➢ Robotics
➢ Desktop etc
![Page 23: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/23.jpg)
REQUIREMENTS
• JAVA VIRTUAL MACHINE (JVM)
• JAVA RUNTIME ENVIRONMENT(JRE)
• contains JVM
• JAVA DEVELOPMENT KIT (JDK)
• contains JVM and Compiler
![Page 24: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/24.jpg)
THE JAVA VIRTUAL MACHINE (JVM)
•JVM provides definitions for the:
• Instruction set (central processing unit [CPU])
• Register set
• Class file format
• Stack
• Garbage-collected heap
• Memory area
• Fatal error reporting
• High-precision timing support
![Page 25: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/25.jpg)
JVM™ TASKS
The JVM performs three main tasks:
• Loads code• Verifies code• Executes code
![Page 26: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/26.jpg)
GARBAGE COLLECTION
• Allocated memory that is no longer needed should bedeallocated.
• In other languages, deallocation is the programmer’sresponsibility.
• The Java programming language provides asystem-level thread to track memory allocation.
• Garbage collection has the following characteristics:
• Checks for and frees memory no longer needed
• Is done automatically
• Can vary dramatically across JVM implementations
![Page 27: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/27.jpg)
JRE VS JDK
• JRE provides the libraries, the Java Virtual Machine (JVM), and other components to run applets and applications written in the Java programming language
• JDK is a superset of JRE, and contains everything that is in JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications
![Page 28: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/28.jpg)
SETTING UP THE ENVIRONMENT
• Install the Java Development Kit
• Set path of the jdk directory
• Create the java program
• Compile and run the java program
![Page 29: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/29.jpg)
THE JAVA APPLICATION ENVIRONMENT PERFORMS AS FOLLOWS:
![Page 30: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/30.jpg)
O U T L I N E
• OV E RV I E W O F C O M P U TAT I O N A L P H YS I C S
• TO O LS O F C O M P U TAT I O N A L P H YS I C S
• I N T RO D U C T I O N TO J AVA
• C O MP O N E N T S O F J AVA
• H A N D S - O N
![Page 31: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/31.jpg)
COMPONENTS OF JAVA
• Class : Blueprint for an Object
• Object : Instance of a class
• Constructor: Object Creator
• Method : Behavior or actions
• Variable: Attribute or properties
![Page 32: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/32.jpg)
COMPONENTS OF JAVA
• CLASS: Blueprint of an Object
• e.g.
• public class Animal {
• }
![Page 33: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/33.jpg)
COMPONENTS OF JAVA • METHOD: Behavior or action of an Object
• e.g.
public void eat(){
// eating goes here
}
public void move(){
// moving goes here
}
![Page 34: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/34.jpg)
COMPONENTS OF JAVA • VARIABLE: Attribute or property of an Object
• e.g.
int no_of_leg = 4;
String color = Blue;
![Page 35: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/35.jpg)
SIMPLE JAVA CODE
public class Greeting{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
• TO SAVE: Greeting.java
• TO COMPILE: javac Greeting.java
• TO RUN: java Greeting
![Page 36: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/36.jpg)
JAVA IDE TOOLS • Java Integrated Development Environment(IDE) Tools:
• Eclipse
• Netbeans
• Intelli J
![Page 37: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/37.jpg)
O U T L I N E
• OV E RV I E W O F C O M P U TAT I O N A L P H YS I C S
• TO O LS O F C O M P U TAT I O N A L P H YS I C S
• I N T RO D U C T I O N TO J AVA
• C O MP O N E N T S O F J AVA
• H A N D S - O N
![Page 38: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/38.jpg)
HANDS-ON• Case study: Equation of Uniformly Accelerated Motion
![Page 39: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/39.jpg)
MISSING PARAMETERS
![Page 40: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/40.jpg)
DETECT THE UNKNOWN
input v, u, a, t, s;
input result;
IF s = ? THEN result = s
ELSE IF v = ? THEN result = v
ELSE IF u= ? THEN result = u
ELSE IF a = ? THEN result = a
ELSE IF t = ? THEN result = t
![Page 41: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/41.jpg)
ALGORITHM FOR EQUATION 1
• IF s = null THEN
CASE result OF
v: v = u + at
print v
break
u: u = v – at
print u
break
a: a = (v – u)/t
print a
break
t: t= (v – u)/a
print t
END CASE
END IF
![Page 42: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/42.jpg)
PROJECTS
• Deployed Oracle Anti-Money Laundry solution (MANTAS) in CENTIF Guinee Conakry and Bissau respectively.
• Deployed WebSphere, DB2 Purescale and Tivoli Workload Scheduler on Central Security Clearing System (CSCS) AIX Servers (Nigeria Stock Exchange).
• E-Commerce: alabanigeria.com gorgeouszone.com
• Website: uglybeat.com 9jalearn.com jetlinkghana.comchipbitssystems.com mazinwosu.com (In view)
• Enterprise: Conoil Supply Chain Management Solution, Jetlink Stock Inventory Solution, River State Gov’t Procurement Solution (SEEFOR Project)
• Mobile: Mazi Nwosu (In view)
![Page 43: COMPUTATIONAL PHYSICS WITH JAVA - Covenant Universityeprints.covenantuniversity.edu.ng/10285/1/Computational... · 2018-03-01 · computational physics. •It is a well-designed,](https://reader034.vdocuments.us/reader034/viewer/2022042022/5e7998b7c477e136712b8140/html5/thumbnails/43.jpg)
C O N C L U S I O N