Open Gressy2113 opened 3 years ago
What do you mean with "the output file contains Nouns instead of histogram data"? Maybe "NaNs"?
If I understand correctly your input, you are first reading the whole trajectories and only then adding to the action list the analysis part. This is not expected to work: data should be analyzed while they are read. When you use plumed driver, the whole input is read first. So, I would suggest to try moving all the ib.SOMETHING
up, before you scan the trajectory.
It is possible that things will work also if you leave CONVERT_TO_FES
and DUMPGRID
at the end though (i.e., you only move up REWEIGHT_METAD
and HISTOGRAM
) , unless PLUMED is so smart to know, while you are scanning the trajectory, that the HISTOGRAM will not be used and so does not compute it.
Giovanni
Yes, excuse me, I meant "NaNs"
I moved strings up, but nothing changed. I also tried to move up only REWEIGHT_METAD and HISTOGRAM, and it didn't help too (and moving ENDPLUMED up and down is also useless).
`
f = open('1.dat' , 'w')
with plumed.Plumed(kernel=kernel) as p:
p.cmd("setMDEngine","driver")
p.cmd("setLogFile","test.log")
p.cmd('setNatoms', 0)
p.cmd("setTimestep", 1.)
p.cmd("setKbT", 1.)
ib=plumed.InputBuilder(toplumed = p, tofile= f, kernel=kernel)
p.cmd("init")
ib.READ(LABEL='cv', FILE=filecv,IGNORE_TIME=True, IGNORE_FORCES=True, VALUES='CV')
ib.READ(LABEL='meta',FILE=filecv,IGNORE_TIME=True, IGNORE_FORCES=True, VALUES='M.rbias')
ib.READ(LABEL='uwa', FILE=filecv,IGNORE_TIME=True, IGNORE_FORCES=True, VALUES='UW.bias')
ib.READ(LABEL='lwa', FILE=filecv,IGNORE_TIME=True, IGNORE_FORCES=True, VALUES='LW.bias')
ib.REWEIGHT_METAD(LABEL='w1', TEMP=300, ARG='meta.rbias')
ib.HISTOGRAM(LABEL='h1',ARG='cv', BANDWIDTH=0.005, GRID_BIN=50, GRID_MAX=0.4, GRID_MIN=-0.4,
KERNEL='gaussian', LOGWEIGHTS='w1')
ib.DUMPGRID(GRID='h1', FILE='/tmp/h.dat')
p.cmd('update')
ib.CONVERT_TO_FES(LABEL='ff', GRID='h1', MINTOZERO=True, TEMP=300)
ib.DUMPGRID(GRID='ff', FILE='/tmp/fes.dat')
stop=np.array((1,),dtype='int')
p.cmd("setStopFlag", stop)
stop[0]=0
i=0
while(True):
p.cmd('calc')
i += 1
if stop[0]!=0:
print(i,stop)
break
ib.ENDPLUMED()
p.cmd('update')
p.cmd('runFinalJobs')
f.close()`
Do you see your commands are correctly processed when you check the test.log file?
Also I would say the two lines with p.cmd('update')
are not needed (calc
implies that statistics are updated as well)
There is test.log file. At the end it is 1 cycle, but file 'CV.00' has 60002 strings (1st is title), so it should be ~60000 cycles
Hello, I have a problem with Python API. The code given below takes results from metadynamics, do reweighting and create histogram. But the output file contains Nouns instead of histogram data. When the same input data process in command line (binary code), histogram calculates in a correct way. So, this code should have a pointer to give array with right histogram and fes data (like h.dat and fes.dat).
`