0% found this document useful (0 votes)
57 views

Computation and Programming in Physics - Data Representation / Graphics

Computation and Programming in Physics - Data Representation / Graphics
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Computation and Programming in Physics - Data Representation / Graphics

Computation and Programming in Physics - Data Representation / Graphics
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Computation and Programming in Physics

Data Representation / Graphics

Syeilendra Pramuditya

Physics Program
Institut Teknologi Bandung
1
2

Data Interpolation
 Data xy
3

Data Interpolation
 Lagrange Interpolation
 Based on Taylor series
 General: Polynomial
 Simplest: Linear, y = ax + b
 And many more methods..

Ref.: A First Course in Computational Physics, Chapter 3, Paul DeVries


4

Lagrange Linear Interpolation


x  x1 x  x2 x  x1 x  x2
p ( x)  f ( x2 )  f ( x1 )  y2  y1
x2  x1 x1  x2 x2  x1 x1  x2

x2,y2

p(x)

x1,y1

2 1 24 5
p ( x  2)  5 3   2  3.67
4 1 1 4 3
5

Lagrange Linear Interpolation


Interpolated data is  x  x2  x  x1 x  x2 1
p x  1   y  y  ( y1  y2 )
at midpoint  2  x2  x1
2
x1  x2
1
2

x2,y2

p(x)

x1,y1

1 4  1
p   p (2.5)  (3  5)  4
 2  2
6

Tabular Data File (x,y,z)

File data akan diberikan


7

2D Map of the Data (x,y,z)


8

2D Interpolation for Plot Smoothing

Data

Interpolated
9

Code Structure
 Read Input Data File
 Interpolate Data
 Write (File/Array) Interpolated Output Data
 Generate 2D map of the data
10

2D Map of the Data (x,y,z)


11

2D Map of the Data (x,y,z)


12

2D Map of the Data (x,y,z)


13

2D Map of the Data (x,y,z)


14

Potential Due to a Point Charge


A positively charged particle produces a positive electric potential.
A negatively charged particle produces a negative electric potential.

Consider a point P at distance R from a fixed particle of positive


charge q. Imagine that we move a positive test charge q0 from point
P to infinity. The path chosen can be the simplest one— a line that
extends radially from the fixed particle through P to infinity.

If Vf =0 (at ∞) and Vi =V (at R). Then, for the magnitude of the


electric field at the site of the test charge,

That gives:

Switching R to r,
15

Potential Due to Point Charges:


The net potential at a point due to a group of point charges can be
found with the help of the superposition principle. First the
individual potential resulting from each charge is considered at the
given point. Then we sum the potentials.

For n charges, the net potential is

r Scalar Equation
16

Potential Due to Point Charges:


17

Code Structure
 Read Input
 How many particles?
 Location of each particle
 Charge of each particle
 Calculation domain (xmin, ymin, xmax, ymax)
 Grid resolution
 Calculate potential at all nodes/grid-points
 Write Output to Datafile

 Generate 2D map of the output data


18

2D Map of the Data V(x,y)


19

Electric Field Vector


 Due to a point charge
20

Electric Field Vector


21

Electric Field Vector


22

Electric Field Vector


 Real magnitude of vector
23

Electric Field Vector


 Equal magnitude of vector
24

Electric Field Vector


 Multiple Charged Particles
The net, or resultant, electric field due to more than one point charge
can be found by the superposition principle. The net electric field at
the position of the test charge is
25

Electric Field Vector


26

Electric Field Vector


27

Electric Field Vector


 Real magnitude of vector
28

Electric Field Vector


 Equal magnitude of vector
29

Code Structure
 Read Input
 How many particles?
 Location of each particle
 Charge of each particle
 Calculation domain (xmin, ymin, xmax, ymax)
 Grid resolution
 Calculate electric field vector at all nodes/grid-
points
 Write Output to Datafile (depends on your
graphic tools)
 Position, magnitude, angle
 x1, y1, x2, y2
 Generate vector map of the output data

You might also like