glotzerlab / hoomd-blue

Molecular dynamics and Monte Carlo soft matter simulation on GPUs.
http://glotzerlab.engin.umich.edu/hoomd-blue
BSD 3-Clause "New" or "Revised" License
323 stars 127 forks source link

Bussi Thermostat Time Constant #1809

Closed WeikangXian closed 1 month ago

WeikangXian commented 1 month ago

Description

I was trying to use the Bussi thermostat to run an NVT simulation. But it shows


TypeError Traceback (most recent call last) Cell In[2], line 32 29 lj.r_cut[('A', 'A')] = 2.5 30 integrator.forces.append(lj) ---> 32 bussi = hoomd.md.methods.thermostats.Bussi(kT=1.5 , tau=0.1) 34 nvt = hoomd.md.methods.ConstantVolume( filter=hoomd.filter.All(), thermostat=bussi ) 36 integrator.methods.append(nvt)

TypeError: Bussi.init() got an unexpected keyword argument 'tau'

I based my script on the available tutorials. It worked fine if I did not define tau at all. It may be because my script is wrong or due to a bug. So I report it here as a bug.

Script

import itertools
import numpy
import hoomd
import gsd.hoomd
import time
import os
import math

m = 4
N_particles = 4 * m**3
spacing = 1.3
K = math.ceil(N_particles ** (1 / 3))
L = K * spacing
x = numpy.linspace(-L / 2, L / 2, K, endpoint=False)
position = list(itertools.product(x, repeat=3))

frame = gsd.hoomd.Frame()
frame.particles.N = N_particles
frame.particles.position = position[0:N_particles]
frame.particles.typeid = [0] * N_particles
frame.configuration.box = [L, L, L, 0, 0, 0]
frame.particles.types = ['A']

with gsd.hoomd.open(name='lattice.gsd', mode='w') as f:
    f.append(frame)

cpu = hoomd.device.CPU()
simulation = hoomd.Simulation(device=cpu, seed=1)
simulation.create_state_from_gsd(filename='lattice.gsd')

integrator = hoomd.md.Integrator(dt=0.005)

cell = hoomd.md.nlist.Cell(buffer=0.4)
lj = hoomd.md.pair.LJ(nlist=cell)
lj.params[('A', 'A')] = dict(epsilon=1, sigma=1)
lj.r_cut[('A', 'A')] = 2.5
integrator.forces.append(lj)

bussi = hoomd.md.methods.thermostats.Bussi(kT=1.5 , tau=0.1)

nvt = hoomd.md.methods.ConstantVolume( filter=hoomd.filter.All(), thermostat=bussi )

integrator.methods.append(nvt)

simulation.operations.integrator = integrator

Input files

N.A.

Output

N.A.

Expected output

I expected my script to generate an initial configuration and define the simulation to be run.

Platform

CPU, GPU, Linux

Installation method

Compiled from source

HOOMD-blue version

4.0.1

Python version

3.11.7

joaander commented 1 month ago

tau was added in HOOMD-blue 4.3.0.