https://github.com/lisechemistry/numerical_methods_master_projects
Numerical projects using Fortran and Python: interpolation/extrapolation of molecular potentials (O₂, C₂H₅), integration and differentiation (average value, VO₂(R)), and model fitting of a spectroscopic Hamiltonian.
https://github.com/lisechemistry/numerical_methods_master_projects
differentiation extrapolation fortran integration interpolation-methods numerical-methods python sobol-sequence
Last synced: 5 months ago
JSON representation
Numerical projects using Fortran and Python: interpolation/extrapolation of molecular potentials (O₂, C₂H₅), integration and differentiation (average value, VO₂(R)), and model fitting of a spectroscopic Hamiltonian.
- Host: GitHub
- URL: https://github.com/lisechemistry/numerical_methods_master_projects
- Owner: LiseChemistry
- License: mit
- Created: 2025-04-09T20:27:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-13T21:00:31.000Z (about 1 year ago)
- Last Synced: 2025-06-21T05:37:34.159Z (about 1 year ago)
- Topics: differentiation, extrapolation, fortran, integration, interpolation-methods, numerical-methods, python, sobol-sequence
- Language: Fortran
- Homepage:
- Size: 313 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 📚 **Numerical Methods – Master Projects**
[](https://en.wikipedia.org/wiki/Fortran)
[](https://www.python.org/)
[](LICENSE)
## 📘 Overview
This repository contains numerical methods projects completed during my Master’s program. The projects involve scientific programming in **Fortran** and **Python**, focusing on:
🔹 **Project 1: Interpolation / Extrapolation**
• Potential of O₂
• Potential of the C₂H₅ radical
🔹 **Project 2: Integration & Differentiation**
• Average value
• Numerical derivatives of VO₂(R)
• Integration
🔹 **Project 3: Model Fitting**
• Spectroscopic Hamiltonian analysis
> 🧠 Developed using **Fortran** for high-performance numerical tasks and **Python** for data fitting and visualization.
---
### Project I: Interpolation/Extrapolation (Fortran)
#### 📌Exercise 1: Potential of O₂
We consider the internuclear potential of the O₂ molecule:
```math
V(R) = -D \left\{1 + c_1(R - R^*) + c_2(R - R^*)^2 + c_3(R - R^*)^3 \right\} e^{-\alpha(R - R^*)}
```
Where:
- D = 3.8886 eV
- R* = 2.2818 a₀
- α = 3.3522498 a₀⁻¹
- c₁ = 3.6445906 a₀⁻¹
- c₂ = 3.9281238 a₀⁻²
- c₃ = 2.0986689 a₀⁻³
This is a model adjusted to experimental spectroscopic data.
We want to interpolate the potential over the interval [1.8, 7]a₀ using these points:
```math
\{ R_q \} = \{1.8, 2.1, 2.4, 2.8, 3.3, 4.0, 5.0, 7.0\}
```
##### 🧩Interpolation Methods:
- Lagrange Polynomial ( L(R) )
- Polynomial in powers of ( 1/R )
- Rational Polynomial (`RatInt.f`)
- Cubic Splines (`Spline.f`)
Plot the interpolation error:
```math
|V(R_i) - V_{\text{Int}}(R_i)|
```
on a **logarithmic scale** for R in [1.8, 10], and compare the behavior of the interpolation and extrapolation methods.
---
#### 📌Exercise 2: Potential of the C₂H₅ Radical
We use the model potential:
```math
V(\phi) = e^{-\alpha \cos(6\phi)}, \quad \alpha = 0.2
```
This potential has the same symmetry properties as the exact one.
##### 🔧Tasks:
- Build an interpolation scheme V̄(φ) using `Minv.f`.
- Determine the minimum number of interpolation points {φ_q} such that the standard deviation:
```math
\phi_{q+\frac{1}{2}} = \frac{1}{2}(\phi_{q+1} + \phi_q)
```
```math
\sigma = \sqrt{ \frac{1}{N - 1} \sum_{q=1}^{N-1} \left[ V(\phi_{q+1/2}) - \bar{V}(\phi_{q+1/2}) \right]^2 } < 10^{-5}
```
---
### Project II: Integration – Differentiation (Fortran)
#### 📌Exercise 1: Average Value
We want to compute the average distance of the electron to the nucleus in the hydrogen atom’s 3s orbital:
```math
\langle r \rangle_{3s} = \langle \phi_{3s} | r | \phi_{3s} \rangle = 4\pi \int_0^\infty \phi_{3s}^2(\vec{r}) r^3 dr
```
With:
```math
\phi_{3s}(\vec{r}) = \frac{1}{\sqrt{4\pi}} \cdot \frac{2}{81\sqrt{3}} \left(\frac{Z}{a_0}\right)^{3/2} (27 - 18\rho + 2\rho^2) e^{-\rho/3}, \quad \rho = \frac{Zr}{a_0}
```
##### 🧩Methods:
- Gauss-Laguerre Quadrature (`Laguerre_Quad.c`)
- Monte Carlo Method (with same RNG seed)
- (Optional) Monte Carlo with Importance Sampling
Compare with the analytical value:
```math
\langle r \rangle_{ns} = \frac{n^2 a_0}{Z} \left(1 + \frac{1}{2}\left(1 - \frac{\ell(\ell + 1)}{n^2} \right)\right)
```
---
#### 📌Exercise 2: Numerical Derivatives of the VO₂ Potential
Reuse the O₂ potential from Project I and compute its first and second derivatives at:
```math
R = R^*
```
Study the effect of:
- Number of points used
- Spacing of points
Compare with the analytical derivatives.
---
#### 📌Exercise 3: Laser Pulse Integration
Consider a laser pulse defined by the function:
```math
A(t) = A_0 \sin(\omega t) e^{-\alpha(t - T)^2}
```
Where:
- ω = 2
- T = 5π
- α = 0.05
##### 🔧Tasks:
- Compute the **fluence** Φ:
```math
\Phi = \int_0^{2T} A^2(t) dt
```
##### 🔧Using:
- Trapezoidal method
- Simpson's rule
Increase the number of integration points until the **relative convergence** reaches 10⁻⁸.
---
### Project III: Model Fitting (Python)
#### 📌Exercise 1: Study of a Spectroscopic Hamiltonian
We consider the vibrational spectroscopic Hamiltonian:
```math
E_{\text{sp}}(n) = T_0 + \sum_{\alpha=1}^{6} \omega_\alpha \left(n_\alpha + \frac{1}{2} \right) + \sum_{\alpha \leq \beta} x_{\alpha\beta} \left(n_\alpha + \frac{1}{2} \right)\left(n_\beta + \frac{1}{2} \right) + \sum_{\alpha \leq \beta \leq \gamma} y_{\alpha\beta\gamma} \left(n_\alpha + \frac{1}{2} \right)\left(n_\beta + \frac{1}{2} \right)\left(n_\gamma + \frac{1}{2} \right)
```
Adjust the parameters **T₀**, {**ωα**}, {**xαβ**}, and {**yαβγ**} using the **least squares method**. These parameters can be determined based on the list {**Eexp(n)**} (see the file `HFCO_exp.dat`), which contains the first **150 calculated vibrational levels** of the HFCO molecule.
##### 🔧Tasks:
- Fit Only ωα and xαβ and use a regular matrix inversion method to perform the least squares fit:
```python
numpy.linalg.inv
```
- Include yαβγ terms. Some of these parameters cannot be determined.
if the state **(n₁ = 1, n₂ = 1, n₃ = 1, n₄ = n₅ = n₆ = 0)** does not appear in the list, then **y₁₂₃** cannot be fitted.
- Test with **Singular Value Decomposition**:
```python
numpy.linalg.svd
```
##### Print:
- The fitted parameters
- The residuals $E_{\text{exp}}(n) - E_{\text{sp}}(n)$ for all levels
---
### License
The package is licensed under the MIT License.