Note for ab-initio calculations

Categories: Chemistry
This post contains some notes I took when learning ab-initio calculations Localized orbital (LOCA) and unitary transformation Localized molecular orbitals are molecular orbitals which are concentrated in a limited spatial region of a molecule, for example a specific bond or a lone pair on a specific atom. They can be used to relate molecular orbital calculations to simple bonding theories, and also to speed up post-Hartree–Fock electronic structure calculations by taking advantage of the local nature of electron correlation.

Read More →

Scope of variables in Fortran

Categories: Code
Fortran has an option of local variables called SAVE. If this option is added, its value will be kept until the end of program. To clarify, let's say if the code is like the following: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 program main integer :: a = 1 write(*,*) "a=",a call add1(a) write(*,*) "a=",a call add1(a) write(*,*) "a=",a end program subroutine add1(a) integer,save :: b integer :: a write(*,*) "b=",b b=1 a = a+b b = b+1 end subroutine No matter how do you compile it, the output will be like the following:

Read More →

Solve a Nonlinear Second Order ODE

Categories: Math
The problem is how to solve the following ODE: $$ \ddot{x} = A\exp\left(-Bx\right)$$ with the following initial condition: $$ x(0)=0,\quad x'(0)=0$$ The actual method is quite traditional. We first make $v(t)=\dot{x}(t)$, then the ODE becomes: $$v\frac{dv}{dx}=A\exp(-Bx)$$ The general solution of it is: $$\frac{v^2}{2}=-\frac{A}{B}\exp(-Bx)+C$$ Using the initial condition: $$\dot{x}=\sqrt{\frac{2A}{B}\left[1-\exp(-Bx)\right]}$$ The tricky part now is we make a another substitution now and make $y=\exp(-Bx)$, then we get: $$-\frac{\dot{y}}{By}=\sqrt{\frac{2A}{B}\left[1-y\right]}$$ Then the following ODE can be easily solved: $$\dfrac{dy}{y\sqrt{1-y}}=-\sqrt{2AB}dt$$ The result: $$\log\left(\dfrac{1-\sqrt{1-y}}{1+\sqrt{1-y}}\right)=-\sqrt{2AB}t$$

Read More →