Ejemplo n.º 1
0
    def __init__(self):

        self.params = initsim.getparams()
        
        if len(self.params['numwindows']) == 1:
            self.windowcentres = [[self.params['firstwindow'][0] + n*self.params['windowsep'][0]] \
                                  for n in range(self.params['numwindows'][0])]
        elif len(self.params['numwindows']) == 2:
            self.windowcentres = [[self.params['firstwindow'][0] + n*self.params['windowsep'][0], \
                                   self.params['firstwindow'][1] + m*self.params['windowsep'][1]] \
                                  for m in range(self.params['numwindows'][1]) \
                                  for n in range(self.params['numwindows'][0])]
        else:
            print " > 2 order parameters not supported"
            exit(0)
                      
        self.dir = os.path.abspath(__file__)
        funcman = funcselector.FuncSelector(self.params)
        self.writexyz = funcman.WriteXyzFunc()
        self.params['simulation'] = 'restart'
        # if queue_name_form supplied, the queue name will be this with the
        # window index appended
        self.queue_name_form = 'unnamed'
        # pickled version of master (wumbrella) parameters 'params.pkl'
        writeoutput.writepickparams(self.params)
        # human readable version 'params.out'
        writeoutput.writeparams(self.params)
Ejemplo n.º 2
0
    def __init__(self):
        """
        Read parameters, get initial positions (and velocities if MD),
        and setup any parameters needed for the simulation.
        """

        # read input parameters and write to file
        self.params = initsim.getparams()
        # pickled version 'params.pkl'
        writeoutput.writepickparams(self.params)
        # human readable version 'params.out'
        writeoutput.writeparams(self.params)

        # From params dictionary create FuncSelector object.  This
        # will handle correct selection of the underlying fortran/C++
        # functions correctly (the functions called depend on the
        # potential, i.e. the value of params['potential'], and also
        # on the type of MC cycle wanted, i.e.  params['mctype'], and
        # on the order parameter desired, params['orderparam'].
        funcman = funcselector.FuncSelector(self.params)
        self.totalenergy = funcman.TotalEnergyFunc()
        self.runcycle = funcman.MCCycleFunc()
        self.orderp = funcman.OrderParamFunc()
        self.writexyz = funcman.WriteXyzFunc()

        # initialize positions (and velocities and forces if we are
        # doing MD rather than MC).
        if self.params['mctype'] == 'md':
            self.positions, \
            self.velocities = initsim.\
            initpositionsvelocities(self.params)
            # Note we only have MD implemented for Gaussian potential
            # at present; the force function should in principle be
            # handled by the FuncSelector interface.
            self.forces = force.gauss_forceslist(self.positions,
                                                 self.params)            
        else:
            # MC simulation.  We initialize positions only.
            self.positions = initsim.initpositions(self.params)

        # write initial positions to file if new simulation
        if self.params['simulation'] == 'new':
            self.writexyz('initpositions.xyz', self.positions,
                          self.params)
            # write initial pickle file that stores both positions and
            # velocities if we are doing an MD simulation.
            if self.params['mctype'] == 'md':
                writeoutput.writemdpick('initpositions.pkl',
                                        self.positions, self.velocities)

        # number of times to call MC cycle function
        self.ncall = int(np.ceil(self.params['ncycle'] /
                                 float(self.params['opsamp'])))

        # number of cycles each time we call MC cycle function
        self.params['cycle'] = min(self.params['ncycle'],
                                   self.params['opsamp'])
Ejemplo n.º 3
0
    def __init__(self):
        """
        Read parameters, get initial positions,
        and setup any parameters needed for the simulation.
        """
        # allow taking index as command line argument
        if len(sys.argv) != 1 and sys.argv[1] == '-w':
            self.iwind = sys.argv[2]
        else:
            self.iwind = ''
        # read input parameters and write to file
        if self.iwind != '' and os.path.exists('params{0}.pkl'.format(
                self.iwind)):
            self.params = pickle.load(open('params{0}.pkl'.format(self.iwind)))
        else:
            self.params = initsim.getparams()
        if self.iwind == '':  #indexed pkl files wil already exist otherwise
            # pickled version 'params.pkl'
            writeoutput.writepickparams(self.params)
            # human readable version 'params.out'
            writeoutput.writeparams(self.params)

        # allow some equilibration cycles
        if self.params['umbequilcycles'] > 0:
            self.params['umbequil'] = True
        else:
            self.params['umbequil'] = False

        # From params dictionary create FuncSelector object.  This
        # will handle correct selection of the underlying fortran/C++
        # functions correctly (the functions called depend on the
        # potential, i.e. the value of params['potential'], and also
        # on the type of MC cycle wanted, i.e.  params['mctype'], and
        # on the order parameter desired, params['orderparam'].
        funcman = funcselector.FuncSelector(self.params)
        self.totalenergy = funcman.TotalEnergyFunc()
        self.runcycle = funcman.MCCycleFunc()
        self.orderp = funcman.OrderParamFunc()
        self.writexyz = funcman.WriteXyzFunc()

        # initialize positions
        self.positions = initsim.initpositions(self.params)

        # write initial positions to file if new simulation
        if self.params['simulation'] == 'new':
            self.writexyz('initpositions{0}.xyz'.format(self.iwind),
                          self.positions, self.params)

        # number of times to call MC cycle function
        self.numbrellacycles = self.params['numbrellacycles']

        # number of cycles each time we call MC cycle function
        self.params['cycle'] = self.params['nunbiased']
Ejemplo n.º 4
0
# full path is the complete path to codeffs.py
fullpath = os.path.abspath(os.path.dirname(sys.argv[0]))
# epath is path to executables lambda0.py, finish.py, takeshot.py
epath = os.path.normpath(os.path.join(fullpath, '..', 'scripts'))
print 'path to scripts lambda0.py, finish.py, takeshot.py is', epath

# can specify a job queue here
qname = 'physics.q'
if qname:
    qstr = '-q %s' % qname
else:
    qstr = ''

# get params and write to pickle file 'params.pkl' for future reading
params = initsim.getparams()
writeoutput.writepickparams(params)

# write params to 'pickle.out' -> human readable version of params.pkl
writeoutput.writeparams(params)

# params needed for job submission
numint = params['numint']
nshots = params['nshots']
nbatch = params['nbatch']
minsuccess = params['minsuccess']
ffsnm = params['ffsname']
ffsre = params['ffsrestart']
# syntactic sugar - if ffsre = FFSNEW, we are starting new simulation
FFSNEW = -1