132x Filetype PDF File size 0.90 MB Source: meskc.ac.in
Semester-6 Core Course – XII PH6 B19: Computational Physics (54 hrs – 3 credits) UNIT I. Introduction to Python Programming: 20 Hrs Concept of high level language, steps involved in the development of a Program – Compilers and Interpreters - Introduction to Python language, Advantages of Python in comparison with other Languages - Different methods of using python: Using python as a calculator, Writing python programs and execution - Inputs and Outputs - Variables, operators, expressions and statements -- Strings, Lists, list functions (len, append, insert, del, remove, reverse, sort, +, *, max, min, count, in, not in, sum), sets, set functions(set, add, remove, in, not in, union, intersection, symmetric difference)-Tuples and Dictionaries, Conditionals, Iteration and looping - Functions and Modules - File input and file output, Pickling. UNIT II . Numerical Methods in physics (Programs are to be discussed in Python) 22 Hrs General introduction to numerical methods, Comparison between analytical and numerical techniques - Curve Fitting: Principle of least squares, fitting a straight line - Interpolation: Finite difference operator, Newton's forward difference interpolation formula, Solution of algebraic equations: Newton-Raphson method - Numerical differentiation and integration: Differnce table, Trapezoidal and Simpson's (1/3) method - Solution of differential equations :Runge Kutta method (Second order) -Taylor's Series : Sin(x) and Cos(x). UNIT III> Introduction to Computational approach in physics 12 Hrs (Programs are to be discussed in Python) One Dimensional Motion: Falling Objects: Introduction – Formulation: from Analytical methods to Numerical Methods - Euler Method, Freely falling body, Fall of a body in viscous medium - Simulation of free fall and numerical integration, Two dimensional motion: Projectile motion (by Euler method)-Motion under an attractive Inverse Squarelaw force Accuracy considerations .(elementary ideas)(Graphics not required, data may be presented in table form) References: (For Python any book can be used as reference. Moreover a number of open articles are available freely in internet. Python is included in default in all GNU/Linux platforms and It is freely downloadable for Windows platform as well. However use of GNU/Linux may be encouraged). 1. www.python.org 2. Python Essential Reference, David M. Beazley, Pearson Education 3. Core Python Programming, Wesley J Chun, Pearson Education 4. Python Tutorial Release 2.6.1 by Guido van Rossum, Fred L. Drake, Jr., editor. This Tutorial can be obtained from website (http://www.altaway.com/resources/python/tutorial.pdf) 5. How to Think Like a Computer Scientist: Learning with Python, Allen Downey , Jeffrey Elkner , Chris Meyers, http://www.greenteapress.com/thinkpython/thinkpython.pdf 6. Numerical Methods in Engineering and Science, Dr. B S Grewal, Khanna Publishers, M E S K C PHYSICS Newdelhi (or any other book) 7. Numerical methods for scientists and engineers, K. Sankara Rao, PHI 8. Introductory methods of numerical analysis, S.S.Shastry , (Prentice Hall of India,1983) 9. Computational Physics, V.K.Mittal, R.C.Verma & S.C.Gupta-Published by Ane Books,4821,Pawana Bhawan,first floor,24 Ansari Road,Darya Ganj,New Delhi-110 002 (For theory part and algorithms. Programs must be discussed in Python)Programming in Python Concept Of Programming Language Microprocessor is the most important part of a computer. With the help of devices and chips a micro- processor can accept instructions and data. It can manipulate this data to take decisions. The step by step instructions based on logics to solve a problem is a computer program. The manufacturer will incorporate the circuits and elements of the microprocessor so that it can perform jobs. Each job is designated with a number in the binary format. So to use microprocessor we have to feed this number. An instruction set written with this number and address of memory location is called a Machine Language Instruction. To solve a problem, we have to develop a detailed and precise step by step method. These steps are called Algorithm or Logical development of program. Each step in this algorithm can be decoded to machine language instructions. This sequence of machine language instructions is known as Machine Language Program. Due to the machine dependency of the language and the difficulty to handle the numbers, debugging become a difficult task. To avoid this, another language is developed. In this, the instructions are some combination of two or three characters which have close resemblance to the corresponding English word for that job. MOV, ADD, HLT etc are examples. A program with this type of instructions is called Assembly Language. A program in the computer can convert the Assembly Language to Machine Language is known as Assembler High Level Language Writing a program in Machine Language or Assembly Language is tiresome. It needs deep understanding of hardware and memorising the operational codes. For this many other languages has been developed. They are generally known as High Level Languages. It is with a set of well defined key words resembling ordinary English statements, which is capable for direct translation of Algorithm easily. BASIC, FORTRAN, C++, PYTHON etc are the examples. In this each instruction is with specific rules of usage. It can be used in any computer regardless of the brand and manufacturer of microprocessor. So this is a machine independent language. The usage of each instruction or key word is confined with rigid rules. Only if we write the instructions within these rules, computer can understand it. These rules like grammar rules in English are known as Syntax Rules. An instruction even if correct in syntax, may led to wrong answers, if it is not properly used. That is, the instruction is with Semantic Error. For instance, the sentence ‘Marry plays violin’ is both syntactically and semantically correct whereas ‘Violin plays Marry’ is syntactically correct, but semantically wrong. A high level language must have the following features. 1. Well defined permitted character set. 2. Ability to represent and manipulate different date types like integer, float, character etc and objects like strings, arrays, list etc. 3. A detailed list of operators (arithmetic, logical, conditional etc.) to act on the data. 4. Instructions for control flow structures on decision making, branching, looping etc. 5. A set of syntax rules to frame the correct instruction with key words and symbols permitted by the M E S K C PHYSICS language. 6. A set of semantic rules to assign correct and unambiguous meaning to a statement. The process of designing, writing, testing, debugging/ troubleshooting, and maintaining the source code is called computer programming. The Evolution of Programming Languages Programming languages fall into three broad categories: Machine languages Assembly languages Higher-level languages Machine Level Languages Machine languages (first-generation languages) are the most basic type of computer languages, consisting of strings of numbers the computer's hardware can use. Different types of hardware use different machine code. For example, IBM computers use different machine language than Apple computers. Assembly Level Languages Assembly languages (second-generation languages) are only somewhat easier to work with than machine languages. To create programs in assembly language, developers use cryptic English-like phrases to represent strings of numbers. The code is then translated into object code, using a translator called an assembler. High Level Languages Higher-level languages are more powerful than assembly language and allow the programmer to work in a more English-like environment. eg:- Ada, Algol,BASIC,COBOL,C,C++,FORTRAN, LISP, PASCAL,PROLOG First HLL is Plankalkül (Konrad Zuse) Higher-level programming languages are divided into three "generations," each more powerful than the last. Third-generation languages Fourth-generation languages Fifth-generation languages Higher-Level Languages - Third-Generation Languages Third-generation languages (3GLs) are the first to use true English-like phrasing, making them easier to use than previous languages. 3GLs are portable, meaning the object code created for one type of system can be translated for use on a different type of system. The following languages are 3GLs: FORTAN, C, COBOL,C++, BASIC, Java, Pascal, ActiveX Higher-Level Languages - Fourth-Generation Languages Fourth-generation languages (4GLs) are even easier to use than 3GLs. 4GLs may use a text-based environment (like a 3GL) or may allow the programmer to work in a visual environment, using graphical tools. M E S K C PHYSICS The following languages are 4GLs: Visual Basic (VB), VisualAge , Authoring environments Advantages of High Level Languages closer to human language user friendly make programming easier and more abstract, i.e. the programmer does not need to come up with the detailed machine instructions machine independent. More portable across platforms. makes complex programming simpler while LLL tend to produce more efficient code Disadvantages of HLL must be translated into machine language(executable program) by a compiler or interpreter Programming features like more generic data structures, run time interpretation & intermediate code files result in slower execution speed higher memory consumption larger binary program size Complier and Interpreter A program in high level language is called Source Code. We can feed this program directly to a computer using any text editor. But microprocessor can understand only machine language. So there will be an elaborate computer program to translate the high level language to machine language. There are two types of translator program available now. They are Interpreter and Compiler. An interpreter reads and executes the high level program line by line. During the execution, if a line is syntactically wrong, it stops the execution with an error message. After correcting it, again we have to start from the beginning. During all executions of same program, computer repeats the same steps, which is highly time consuming. The mode of operation of compiler is entirely different. Instead of executing an instruction, compiler converts the entire program in to machine language and stores it to a file. During compilation, the compiler will go through the entire program and will list out all errors with the line numbers. We can correct it and compile again. If the program is free from syntax errors, compiler will convert the program to machine language and stores in a location. We can directly execute the program from this stored file. So we need the compilation only once. M E S K C PHYSICS
no reviews yet
Please Login to review.