0% found this document useful (0 votes)
27 views10 pages

CHALLENGINGTASK

vit bhopal challenging task phy1003

Uploaded by

anika.24bai10420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views10 pages

CHALLENGINGTASK

vit bhopal challenging task phy1003

Uploaded by

anika.24bai10420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

COMPUTATIONAL PHYSICS

Challenging Task
Winter Semester 2024 -2025
COURSE CODE :PHY1003
SLOT: C11+C12+C13

SUBMITTED TO: SUBMITTED BY: ANIKA SAXENA

DR. PRADEEP KUMAR KASHYAP REG. NO. :24BAI10420


EXPERIMENT -1

AIM : To create a line plot using the appropriate data. You must
show at least three different lines in the same figure using different
colors (3 Marks)

Software Required : Python, Jupyter notebook

Theory:

A line plot, also known as a line graph or dot plot, is a way to display data using
symbols, typically dots or Xs, above a number line. It's a simple visual representation
that shows the frequency or occurrence of each data value along a continuous scale.

Code:
import [Link] as plt

import numpy as np

# Sample Data

x = [Link](0, 10, 100)

y1 = x*2

y2 = 2*x+1

y3 = 3*x+4

[Link](figsize=(8, 5))

[Link](x, y1, label='x*2', color='blue', linestyle='-')

[Link](x, y2, label='2*x+1', color='red', linestyle='--')

[Link](x, y3, label='3*x+4', color='green', linestyle=':')


[Link]("X ")

[Link]("Y ")

[Link]("Line Plot with Three Different Functions")

[Link]()

[Link](True)

[Link]()

Output:

Precautions :
1. Make sure that data is in correct format.
2. Choose the appropriate plot type.
3. Set the axis labels and limits.
4. Add the title and legend.
5. Save the plot in a file format.

EXPERIMENT -2

AIM : Python code to display Planck’s function. The blackbody curve must be
displayed for the temperatures of 3130, 4290, and 5778 K. Also, the wavelength
should vary from 0 to 2000 Å. (4 Marks)

Software Required : Python, Jupyter notebook


Theory:
The Planck’s function is used to show the energy spectrum of a black body of temperature T, and it is as
follows.

Where h = Planck’s constant,

c=speed of light,

T =temperature, and

λ =Wavelength , respectively.

Code:
import numpy as np

import [Link] as plt

h = 6.626e-34 # Planck's constant (J·s)


c = 3.0e8 # Speed of light (m/s)

k = 1.38e-23 # Boltzmann constant (J/K)

# Function for Planck’s Law

def planck(wavelength, temperature):

wavelength_m = wavelength * 1e-10 # Convert Å to meters

return (2*h*c**2) / (wavelength_m**5 * ([Link]((h*c) /


(wavelength_m*k*temperature)) - 1))

# Wavelength range (0 to 10000 Å)

wavelengths = [Link](1, 10000, 1000)

# Temperatures to plot

temperatures = [3130, 4290, 5778]

[Link](figsize=(8, 5))

for T in temperatures:

[Link](wavelengths, planck(wavelengths, T), label=f"T = {T} K")

[Link]("Wavelength (Å)")

[Link]("Spectral Radiance")

[Link]("Blackbody Radiation Curves")

[Link]()

[Link](True)

[Link]()
Output:

Precautions :
1. Make sure that data is in correct format.
2. Choose the appropriate plot type.
3. Set the axis labels and limits.
4. Add the title and legend.
5. Save the plot in a file format.
EXPERIMENT -3

AIM : Suppose a golfer hits a ball with a velocity of 45 m/s at an angle of 20° to the
horizontal. Write a code to estimate the position coordinates of the ball at 5
different times. (3 Marks)

Software Required : Python, Jupyter notebook

Theory:

Using projectile motion formula

Code:
import numpy as np

import [Link] as plt

# Given values

v0 = 45 # Initial velocity (m/s)

theta = [Link](20) # Convert degrees to radians

g = 9.81 # Acceleration due to gravity (m/s^2)

times = [Link](0, 5, 5) # Five selected time points

x_positions = v0 * [Link](theta) * times

y_positions = v0 * [Link](theta) * times - 0.5 * g * times**2

print("Time (s) | X Position (m) | Y Position (m)")

print("----------------------------------------")
for t, x, y in zip(times, x_positions, y_positions):

print(f"{t:.2f} | {x:.2f} | {y:.2f}")

[Link](figsize=(8, 5))

[Link](x_positions, y_positions, color="red", label="Estimated Positions",


marker="o")

[Link]("X Position (m)")

[Link]("Y Position (m)")

[Link]("Golf Ball Trajectory at Selected Time Intervals")

[Link]()

[Link](True)

[Link]()

Output:
Precautions :
1. Make sure that data is in correct format.
2. Choose the appropriate plot type.
3. Set the axis labels and limits.
4. Add the title and legend.
5. Save the plot in a file format.

You might also like