Ejemplo n.º 1
0
    def testTraj(self):
        integrator = metropolisMonteCarloIntegrator()
        ha = OneD.harmonicOscillatorPotential(x_shift=-5)
        hb = OneD.harmonicOscillatorPotential(x_shift=5)
        pot = OneD.linearCoupledPotentials(Va=ha, Vb=hb)
        sys = perturbedSystem(temperature=300.0,
                              potential=pot,
                              sampler=integrator)

        lam = 0.5
        sys.lam = lam
        ens = self.convBelt(0.0, 1, system=sys)
Ejemplo n.º 2
0
    def test_run_step(self):
        integrator = metropolisMonteCarloIntegrator()
        ha = OneD.harmonicOscillatorPotential(x_shift=-5)
        hb = OneD.harmonicOscillatorPotential(x_shift=5)
        pot = OneD.linearCoupledPotentials(Va=ha, Vb=hb)
        sys = perturbedSystem(temperature=300.0,
                              potential=pot,
                              sampler=integrator)

        ens = self.convBelt(0.0, 1, system=sys)
        ens.calculate_total_ensemble_energy()
        ens.run()
        ens.calculate_total_ensemble_energy()
        ens.get_replicas_positions()
Ejemplo n.º 3
0
def interactive_conveyor_belt(conveyorBelt=None, numsys:int=8, nbins:int=100, steps:int=100):
    
    #if none given build cvb
    if(isinstance(conveyorBelt, type(None))):
        import ensembler.potentials.OneD as pot
        import ensembler.system.perturbed_system as system
        import ensembler.ensemble.replicas_dynamic_parameters as cvb
        import ensembler.integrator as integ

        integrat = integ.stochastic.metropolisMonteCarloIntegrator()
        potential = pot.linearCoupledPotentials(Va=pot.harmonicOscillator(k=1.0), Vb=pot.harmonicOscillator(k=2.0))
        syst = system.perturbedSystem(potential=potential , integrator=integrat)
        conveyorBelt=cvb.ConveyorBelt(0.0, 8, system=syst, build=False)
        conveyorBelt.simulate(steps)

    (cvb_traj, systrajs) = conveyorBelt.get_trajs()

    if(len(cvb_traj)==0):
        raise IOError("Could not find any conveyor belt simulation in conveyorbelt traj. Please simulate first.")

    bins=np.zeros(nbins)
    dhdlbins=np.zeros(nbins)
    for i in systrajs:
        for j in range(systrajs[i].shape[0]):
            index=int(np.floor(systrajs[i].lam[j]*nbins))
            if index == nbins:
                index=nbins-1
            bins[index]+=1
            dhdlbins[index]+=systrajs[i].dhdlam[j]
    dhdlbins/=bins
    ene = np.cumsum(dhdlbins)/nbins

    lam = np.linspace(0, 1, nbins)
    nReps=conveyorBelt.nReplicas
    
    def redraw(CapLam, M):
        plotEnsembler(lam, ene, CapLam=np.deg2rad(CapLam), M=M)
        

    #build layout and components
 
    
    player = ipywidgets.Play(value=0, min=0, max=360, step=1,
                            description="rotate")
    capLam_slider = ipywidgets.IntSlider(value=0, min=0, max=360, step=1, 
                                         orientation='vertical',
                                         description="Capital Lambda", 
                                         continous_update=True)
    nReplicas_slider = ipywidgets.IntSlider(value=8, min=2, max=20, step=1, 
                                            orientation='vertical',
                                            description="number of Replicas")

    ipywidgets.jslink((capLam_slider, 'value'), (player, 'value'))

    interactive_plot = ipywidgets.interactive_output(redraw, 
                                   {'CapLam':capLam_slider, 
                                   'M':nReplicas_slider})

    controls = ipywidgets.VBox([player, ipywidgets.HBox([capLam_slider, nReplicas_slider])])
    
    app = ipywidgets.AppLayout(header=None,
          left_sidebar=controls,
          center=interactive_plot,
          right_sidebar=None,
          footer=None,
          align_items="center")
          
    
    display(app)
    return app