# obtaining the viscosity of mixture from NAMD output file

From: Kosar Khajeh (khajeh.k.2005_at_gmail.com)
Date: Thu Jul 16 2020 - 08:13:30 CDT

```----
Dear NAMD users,
I have used the green kubo method to calculate the viscosity based on the (
http://www.lennardjones.com/blogs/pr/viscosity.html). I wrote a fortran
code to obtain the viscosity based on the NAMD output file (i mean pressure
data at every time step). In the case of the water box, there was a good
agreement between my result and experimental value for viscosity. My goal
is to simulate the mixture of the Phenyl propionic acid  and choline
chloride in the box.  The problem is raised when I calculate the viscosity
for this mixture system by using my fortran code. Unfortunately, the
viscosity value during time is not converged and it is not in
reasonable range, as well. I do not know what the problem is !...I have
below questions...Any suggestion and help is appreciated.
1-This method is not applicable for calculating the viscosity of the
mixture? Or should I make some modification in method or code?
2- My code has some problems? (However it is working well for the water
system).
3- Do you know how I can calculate the viscosity by using data obtained
from the NAMD simulation?
Please let me know if you need output data to check the code. I will send
it to you.
Again thank you for your time and consideration in advance.
Best regards
Kosar
*The fortran code;*
program GreenKobu
implicit none
INTEGER::K,M,N,S,Nchain,DM,DN
REAL::T
double
precision,allocatable::Pxy(:),Pxz(:),Pyz(:),SUMxy(:),SUMxz(:),SUMyz(:),SUMxyz(:)
double precision::SUMorigins,Viscosity,Volume,Kb
K=1000001
DN=1
DM=1
Nchain=K/DN
allocate(Pxy(K),Pxz(K),Pyz(K),SUMxy(K),SUMxz(K),SUMyz(K),SUMxyz(K))
Volume=137299.0034E-30
Kb=1.38E-23
T=321
!  PRINT*,Volume
!PRINT*,Pxy
DO M=1,K,DM
SUMxy(M)=0.0
SUMxz(M)=0.0
SUMyz(M)=0.0
SUMxyz(M)=0.0
DO N=1,K,DN
SUMxy(M)=SUMxy(M)+Pxy(N)*Pxy(M)
SUMxz(M)=SUMxz(M)+Pxz(N)*Pxz(M)
SUMyz(M)=SUMyz(M)+Pyz(N)*Pyz(M)
END DO
!PRINT*,"SUMxy(",M,")",SUMxy(M)
SUMxyz(M)=SUMxy(M)+SUMxz(M)+SUMyz(M)
END DO
SUMorigins=0.0
DO S=1,K,DM
SUMorigins=SUMorigins+SUMxyz(S)
END DO
Viscosity=(Volume/(Kb*T*3))*(SUMorigins/Nchain)
!Viscosity=SUMorigins/Nchain
PRINT*,"Viscosity=",Viscosity
end program GreenKobu
```

This archive was generated by hypermail 2.1.6 : Thu Dec 31 2020 - 23:17:13 CST