Пример #1
0
def main():
    sc = [0.05, 0.05, 10.0]

    ns, ms = [], []
    md1s, md2s = [], []
    ints = []

    end = '0'
    while end == '0':
        ns.append(int(input("Input N: ")))
        ms.append(int(input("Input M: ")))

        p = float(input("Enter parameter (tao): "))

        md1s.append(
            int(input("Outer integration mode (0 - Gauss, 1 - Simpson): ")))

        md2s.append(
            int(input("Inner integration mode (0 - Gauss, 1 - Simpson): ")))

        lm = [[0, pi / 2], [0, pi / 2]]

        ints.append(
            inter.Integrator(lm, [ns[-1], ms[-1]], [md1s[-1], md2s[-1]]))

        print("Result with {:.2f} as "
              "a parameter is {:.7f}".format(p, ints[-1](p)))

        end = input("Stop execution?: ")

    plot.plot(ints, sc, ns, ms, md1s, md2s)
Пример #2
0
if not os.path.exists(newpath):
    os.makedirs(newpath)

newpath = os.path.join(os.getcwd(), dataFileNameEigenVectors)
if not os.path.exists(newpath):
    os.makedirs(newpath)

newpath = os.path.join(os.getcwd(), dataFileEnergy)
if not os.path.exists(newpath):
    os.makedirs(newpath)

# simulation class sampler takes integrator class with chosen parameters as input
integrator = integrator.Integrator(model=mdl,
                                   gamma=gamma,
                                   temperature=temperature,
                                   temperatureAlpha=temperatureAlpha,
                                   dt=dt,
                                   massScale=massScale,
                                   gammaScale=gammaScale,
                                   kappaScale=kappaScale)

## load initial condition from file
# IC = md.load('alanine_start_state_IC.h5')
# # remove first dimension - the intial condition has shape (1,nrParticles, spaceDimension) when taken from trajectory
# InitialPosition = np.squeeze(IC.xyz)
# integrator.x0 = InitialPosition * mdl.x_unit

general_sampler = sampler.Sampler(
    model=mdl,
    integrator=integrator,
    algorithm=iAlgo,
    diffusionMapMetric=diffMapMetric,
Пример #3
0
    Returns
    -------
    
    Float for P/P_e
    """

    Term1 = 4.0 / (math.pi**2)
    Term2 = intg.get(f2, 0, math.pi / 2.0, 1e-6, alpha)**2

    return Term1 * Term2


if __name__ == '__main__':
    print("Solve for alpha")

    intg = I.Integrator(I.gaussian2, I.gaussian4)

    ListA = []
    ListX = []
    ListY = []
    ListP = []

    table = PrettyTable(["X_g/L", "alpha", "Y_b/L", "P/P_e"])

    for XgOnL in (0.99, 0.95, 0.9, 0.5, 0):
        ListX.append(XgOnL)
        ListA.append(
            solvebisect(optimiseXgOnL, 0.01, limit * math.pi, 1e-6, XgOnL,
                        intg))
        ListY.append(getYbOnL(ListA[-1], intg))
        ListP.append(getPOnPe(ListA[-1], intg))
Пример #4
0
                    type=int,
                    default=1,
                    help='Stride the trajectory modulo modnr.')

args = parser.parse_args()
# folder where the data is saved
dataFolderName = args.dataFolder
nrSteps = args.nrSteinSteps
steinStepSize = args.steinStepSize
modnr = args.modnr

# intialize sampler class together wuth the model
mdl = model.Model('Alanine')
intg = integrator.Integrator(model=mdl,
                             gamma=1.0 / unit.picosecond,
                             temperature=300 * unit.kelvin,
                             dt=2.0 * unit.femtosecond,
                             temperatureAlpha=300 * unit.kelvin)
smpl = sampler.Sampler(model=mdl,
                       integrator=intg,
                       algorithm=0,
                       dataFileName='Data')

# stein
st = stein.Stein(smpl, dataFolderName, modnr=modnr)
# change the stein step size
st.epsilon_step = unit.Quantity(steinStepSize, smpl.model.x_unit)**2
print('Running steinIS on ' + repr(len(st.qInit)) + ' points')
np.save(dataFolderName + '/stein_initial.npy', st.qInit)

#run stein
Пример #5
0
# X0=mdl.testsystem.positions.value_in_unit(mdl.x_unit)





temperature =  T * unit.kelvin#300 * unit.kelvin


gamma = 1.0 / unit.picosecond
dt = 2.0 * unit.femtosecond

temperatureAlpha= (T)* unit.kelvin

# simulation class sampler takes integrator class with chosen parameters as input
integrator=integrator.Integrator( model=mdl, gamma=gamma, temperature=temperature, dt=dt,  temperatureAlpha=temperatureAlpha)
smpl=sampler.Sampler(model=mdl, integrator=integrator, algorithm=0, dataFileName='Data')



newpath = os.path.join(os.getcwd(),simulationFolder)
if not os.path.exists(newpath):
        os.makedirs(newpath)

X_FT = helpers.loadData(folderName+dataName+'/'+modelName+'/'+methodName+'/Traj/*.h5', mdl.testsystem.topology)

X_FT=X_FT[::modnr]
print('Data length is '+repr(len(X_FT)))

#compute collective variable
r=colective_variable(X_FT)