def EvalProps(): """Evaluate thermodynamic properties """ density = _mdsim_globals['density'] deltaT = _mdsim_globals['deltaT'] mol = _mdsim_globals['mol'] nMol = _mdsim_globals['nMol'] uSum = _mdsim_globals['uSum'] virSum = _mdsim_globals['virSum'] vSum = VecR() vvMax : float = 0. vvSum : float = 0. for m in mol: rv_add(vSum, m) vv = rv_dot(m, m) vvSum += vv vvMax = max([vvMax, vv]) _mdsim_globals['dispHi'] += math.sqrt(vvMax) * deltaT if _mdsim_globals['dispHi'] > 0.5 * _mdsim_globals['rNebrShell']: _mdsim_globals['nebrNow'] = True _mdsim_globals['vSum'] = vSum _mdsim_globals['kinEnergy'].val = 0.5 * vvSum / nMol _mdsim_globals['totEnergy'].val = \ _mdsim_globals['kinEnergy'].val + uSum / nMol _mdsim_globals['pressure'].val = density * (vvSum + virSum) / (nMol * NDIM)
def InitVels(): """Initialize the molecular velocities """ mol = _mdsim_globals['mol'] nMol = _mdsim_globals['nMol'] velMag = _mdsim_globals['velMag'] vSum = VecR(x=0., y=0., z=0.) for m in mol: m.rv = VecR() rv_rand(m) rv_scale(m, velMag) rv_add(vSum, m) _mdsim_globals['vSum'] = vSum # Scale molecular velocities for m in mol: rv_sadd(m, -1. / nMol, vSum)
def EvalProps(): """Evaluate thermodynamic properties """ density= _mdsim_globals['density'] mol = _mdsim_globals['mol'] nMol = _mdsim_globals['nMol'] uSum = _mdsim_globals['uSum'] virSum = _mdsim_globals['virSum'] vSum = VecR() vvSum : float = 0. for m in mol: rv_add(vSum, m) vvSum += rv_dot(m, m) _mdsim_globals['vSum'] = vSum _mdsim_globals['kinEnergy'].val = 0.5 * vvSum / nMol _mdsim_globals['totEnergy'].val = \ _mdsim_globals['kinEnergy'].val + uSum / nMol _mdsim_globals['pressure'].val = density * (vvSum + virSum) / (nMol * NDIM)