material for the course "Stellar Formation and Evolution" at NCU at the 2nd semester of academic year 2021
For the session on 03/May/2022, we need Python, Numpy, Scipy, and Matplotlib. If you do not have these software installed on your computer, try to install them.
Things you need for this hands-on session:
- a computer
- Python
- Numpy, Scipy, and Matplotlib
- your favourite web browser to access to https://github.com/
- your favourite text editor to modify codes
- your favourite terminal emulator to execute Python scripts
The script "simple.py" is for solving the equation dy/dx=-ky. Try following.
% ./simple.py
or you may try following.
% python3.9 simple.py
If your pytyhon executable is "python3.8", then try following.
% python3.8 simple.py
If your python executable is "python" instead of "python3.9" or "python3.8", then try following.
% python simple.py
You will find a file "simple.png" after successful execution of the script. Display the file "simple.png"
% feh -dF simple.png
The script "eqmotion.py" is for solving the equation of motion. This script simulate the orbital motion of a planet around a star. Try following.
% ./eqmotion.py -vy0 1.3 -t 30 -o planet
Then, you find may PNG files generated by this script. Next, make a MP4 movie file using ffmpeg command.
% ffmpeg5 -f image2 -start_number 0 -framerate 30 -i planet_%08d.png -an -vcodec libx264 -pix_fmt yuv420p -threads 12 planet.mp4
If your ffmpeg command is "ffmpeg" instead of "ffmpeg5", then try following.
% ffmpeg -f image2 -start_number 0 -framerate 30 -i planet_%08d.png -an -vcodec libx264 -pix_fmt yuv420p -threads 12 planet.mp4
Play the file "planet.mp4"
% mplayer planet.mp4
If you would like to add an audio track to your video file, then try following
% ffmpeg -i planet.mp4 -i audiofile.f251.webm -c:v copy planet_with_audio.mp4
The script "laneemden.py" is for solving Lane-Emden equation, and the script "plot_polytrope.py" is for plotting results. Try following.
% ./laneemden.py -n 0.0 -o laneemden_n00.data
% ./laneemden.py -n 0.5 -o laneemden_n05.data
% ./laneemden.py -n 1.0 -o laneemden_n10.data
% ./laneemden.py -n 1.5 -o laneemden_n15.data
% ./laneemden.py -n 2.0 -o laneemden_n20.data
% ./laneemden.py -n 2.5 -o laneemden_n25.data
% ./laneemden.py -n 3.0 -o laneemden_n30.data
% ./laneemden.py -n 3.5 -o laneemden_n35.data
% ./laneemden.py -n 4.0 -o laneemden_n40.data
% ./laneemden.py -n 4.5 -o laneemden_n45.data
Then, try following to generate plots.
% ./plot_polytrope.py laneemden_n*.data
Display plots.
% feh -dF polytrope*.png