hoomd.md.update.mueller_plathe_flow then how does this command work and how would I use it to get a viscosity value?quantities=['pressure_xy],
period=log_dump_period(Preferrarably smaller than 10, set to 1 if your number of time steps is not too large),
overwrite=True);
- P = -\tau, Therefore, you are simply saving the negative value of the stress.
And
\mu = -\tau / \Dot{\gamma};Use Matlab, Python etc. to post-process the output file. I recommend to average over each 500-1000 time steps to cancel out the noises.
P.S.
If you need to modify the pressure equation according to your shearing system etc. you can simply modify the ComputeThermo.cc file (/hoomd-Directory/hoomd/ComputeThermo.cc) and recompile the package. That's where the pressure components are calculated.
Best,
--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/98cd37aa-7eae-432a-855e-6895e82fed50%40googlegroups.com.
Hi,This is one way that I know of:- Save the pressure quantities that I need. for instance, if there is shearing in xy:hoomd.analyze.log(filename='Name_Of_File.log',quantities=['pressure_xy],
period=log_dump_period(Preferrarably smaller than 10, set to 1 if your number of time steps is not too large),
overwrite=True);- P = -\tau, Therefore, you are simply saving the negative value of the stress.And\mu = -\tau / \Dot{\gamma};Use Matlab, Python etc. to post-process the output file. I recommend to average over each 500-1000 time steps to cancel out the noises.P.S.If you need to modify the pressure equation according to your shearing system etc. you can simply modify the ComputeThermo.cc file (/hoomd-Directory/hoomd/ComputeThermo.cc) and recompile the package. That's where the pressure components are calculated.Best,
On Tue, Oct 8, 2019 at 1:15 PM molecular dynamics <marm...@gmail.com> wrote:
Hello Hoomd users,--I am working on a simulation of a gas with the end goal of calculating its viscosity. I have completed the simulation. I was wondering what is the best way to obtain the viscosity? Does hoomd have way to calculate viscosity maybe using the velocity correlation function? If the best way is to usehoomd.md.update.mueller_plathe_flowthen how does this command work and how would I use it to get a viscosity value?Thank you in advance
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/98cd37aa-7eae-432a-855e-6895e82fed50%40googlegroups.com.
import scipy
data_file = 'md_methanol_data.hdf5'
time = nlread(data_file, object_id="Time")[-1]
pressure_tensor = nlread(data_file, object_id="Pressure")[-1]
volume_avg = nlread(data_file, object_id="Volume_Average")[-1]
temperature = nlread(data_file, object_id="Temperature")[-1]
time_step = nlread(data_file, object_id="Time_Step")[-1]
# Reduce down the data by the factor given
# 1 uses all of the gathered data, 10 uses one 10th
# This can be used to speed getting the autocorrelation function
factor = 1
pressure_tensor = pressure_tensor[::factor,:,:]
time = time[::factor]
# Calculate the shear components of the pressure tensor and place them in a convenient array
N = pressure_tensor.shape[0]
P_shear = numpy.zeros((5,N), dtype=float) * Pa
P_shear[0] = pressure_tensor[:N,0,1]
P_shear[1] = pressure_tensor[:N,0,2]
P_shear[2] = pressure_tensor[:N,1,2]
P_shear[3] = (pressure_tensor[:N,0,0] - pressure_tensor[:N,1,1]) / 2
P_shear[4] = (pressure_tensor[:N,1,1] - pressure_tensor[:N,2,2]) / 2
# Calculate the 5 ACF together then average them
# Note that they are only N/2 the length of the data
# because beyond that there are not enough available time windows
# to be accurate
size = int(N/2)
ACF = numpy.zeros((5,size), dtype=float) * Pa**2
for t in range(size):
ACF[:,t] = numpy.mean(P_shear[:,:N-t] * P_shear[:,t:])
ACF_avg = ACF.mean(axis=0)
# Plotting the ACF
pylab.figure()
pylab.plot(time[:ACF_avg.shape[0]].inUnitsOf(ps), ACF_avg.inUnitsOf(GPa**2), label='ACF')
pylab.xlabel('Time (ps)')
pylab.ylabel('ACF (GPa)')
pylab.legend()
pylab.show()
# Integrate the ACF to get the viscosity
# Note that units need to be put back in because the
# scipy function call strips them
kbT = boltzmann_constant * temperature
ACF_avg *= volume_avg / (kbT)
gk_raw = scipy.integrate.cumtrapz(
y=ACF_avg.inUnitsOf(Pa),
dx=time_step.inUnitsOf(Second)
)
viscosity = gk_raw * Pa * Second
# Plotting the time evolution of the viscosity estimate
pylab.figure()
pylab.plot(time[:viscosity.shape[0]].inUnitsOf(ps), viscosity.inUnitsOf(Pa*millisecond), label='Viscosity')
pylab.xlabel('Time (ps)')
pylab.ylabel('Viscosity (cP)')
pylab.legend()
pylab.show()
hoomd.analyze.log(filename='pressure.log', quantities=('pressure_xx','pressure_xy','pressure_xz','pressure_yy','pressure_yz','pressure_zz'), period=10)