Beispiel #1
0
def main():
    parser = argparse.ArgumentParser(
        description=
        "do nested sampling on a p[article in a n-dimensional Harmonic well")
    #    parser.add_argument("--db", type=str, nargs=1, help="database filename",
    #                        default="otp.db")
    parser.add_argument("-K",
                        "--nreplicas",
                        type=int,
                        help="number of replicas",
                        default=300)
    parser.add_argument("-A",
                        "--ndof",
                        type=int,
                        help="number of degrees of freedom",
                        default=4)
    parser.add_argument("-P",
                        "--nproc",
                        type=int,
                        help="number of processors",
                        default=1)
    parser.add_argument("--trivparal",
                        action='store_true',
                        help="set whether to do trivial parallelisation",
                        default=False)
    parser.add_argument(
        "-q",
        action="store_true",
        help="turn off verbose printing of information at every step")
    args = parser.parse_args()

    system = HarParticle(args.ndof, Emax_init=1000.)
    mcrunner = HarRunner(system)
    #    ns = NestedSamplingSerial(system, args.nreplicas, mcrunner,
    #                              verbose=not args.q)
    ns = NestedSampling(system,
                        args.nreplicas,
                        mcrunner,
                        nproc=args.nproc,
                        triv_paral=args.trivparal,
                        verbose=not args.q)
    print "harmonic particle ndof", args.ndof
    run_nested_sampling(ns, label="hparticle", etol=.00000001)
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser(description="do nested sampling on a p[article in a n-dimensional Harmonic well")
#    parser.add_argument("--db", type=str, nargs=1, help="database filename",
#                        default="otp.db")
    parser.add_argument("-K", "--nreplicas", type=int, help="number of replicas", default=300)
    parser.add_argument("-A", "--ndof", type=int, help="number of degrees of freedom", default=4)
    parser.add_argument("-P", "--nproc", type=int, help="number of processors", default=1)
    parser.add_argument("--trivparal", action='store_true', help="set whether to do trivial parallelisation",default=False)
    parser.add_argument("-q", action="store_true", help="turn off verbose printing of information at every step")
    args = parser.parse_args()


    system = HarParticle(args.ndof, Emax_init=1000.)
    mcrunner = HarRunner(system)
#    ns = NestedSamplingSerial(system, args.nreplicas, mcrunner, 
#                              verbose=not args.q)
    ns = NestedSampling(system, args.nreplicas, mcrunner, nproc=args.nproc, 
                        triv_paral=args.trivparal, verbose=not args.q)
    print "harmonic particle ndof", args.ndof
    run_nested_sampling(ns, label="hparticle", etol=.00000001)
Beispiel #3
0
def run_nested_sampling_lj(system, nreplicas=300, mciter=1000, target_ratio=0.7, label="test", 
                           minima=None, use_compiled=True, nproc=1,
                           triv_paral=True, minprob=1, maxiter=1e100, **kwargs):
    takestep = RandomDisplacement(stepsize=0.07)
    accept_tests = system.get_config_tests()

    if type(system) is  LJClusterNew:
        if use_compiled:
            mc_runner = MonteCarloCompiled(system.radius)
 #       import pickle
 #       with open("testpickle", "w") as pout:
 #           pickle.dump(mc_runner, pout)
        else:
            mc_runner = MonteCarloChain(system.get_potential(), takestep, accept_tests=accept_tests)
        print "using the compiled MC = ", use_compiled
    elif type(system) is HarParticle:
        mc_runner = HarRunner(system)
        print "using HarRunner"
    elif type(system) is IsingSystem:
        mc_runner = IsingRunnerC(system)
        print "using IsingRunner"
    else:
        raise TypeError('system type is not known')
       
        
    print "using", nproc, "processors"
    
    if minima is not None:
        assert(len(minima) > 0)
        print "using", len(minima), "minima"
        ns = NestedSamplingBS(system, nreplicas, mc_runner, minima, 
                              mciter=mciter, target_ratio=target_ratio,stepsize=0.07,
                              nproc=nproc, triv_paral=triv_paral, minprob=minprob, **kwargs)
    else:
        ns = NestedSampling(system, nreplicas, mc_runner, 
                            mciter=mciter, target_ratio=target_ratio,stepsize=0.07,
                            nproc=nproc, triv_paral=triv_paral, **kwargs)
    etol = 0.01

    ns = run_nested_sampling(ns, label, etol, maxiter=maxiter)
    return ns
Beispiel #4
0
def run_nested_sampling_lj(system,
                           nreplicas=300,
                           mciter=1000,
                           target_ratio=0.7,
                           label="test",
                           minima=None,
                           use_compiled=True,
                           nproc=1,
                           triv_paral=True,
                           minprob=1,
                           maxiter=1e100,
                           **kwargs):
    takestep = RandomDisplacement(stepsize=0.07)
    accept_tests = system.get_config_tests()

    if type(system) is LJClusterNew:
        if use_compiled:
            mc_runner = MonteCarloCompiled(system.radius)

#       import pickle
#       with open("testpickle", "w") as pout:
#           pickle.dump(mc_runner, pout)
        else:
            mc_runner = MonteCarloChain(system.get_potential(),
                                        takestep,
                                        accept_tests=accept_tests)
        print "using the compiled MC = ", use_compiled
    elif type(system) is HarParticle:
        mc_runner = HarRunner(system)
        print "using HarRunner"
    elif type(system) is IsingSystem:
        mc_runner = IsingRunnerC(system)
        print "using IsingRunner"
    else:
        raise TypeError('system type is not known')

    print "using", nproc, "processors"

    if minima is not None:
        assert (len(minima) > 0)
        print "using", len(minima), "minima"
        ns = NestedSamplingBS(system,
                              nreplicas,
                              mc_runner,
                              minima,
                              mciter=mciter,
                              target_ratio=target_ratio,
                              stepsize=0.07,
                              nproc=nproc,
                              triv_paral=triv_paral,
                              minprob=minprob,
                              **kwargs)
    else:
        ns = NestedSampling(system,
                            nreplicas,
                            mc_runner,
                            mciter=mciter,
                            target_ratio=target_ratio,
                            stepsize=0.07,
                            nproc=nproc,
                            triv_paral=triv_paral,
                            **kwargs)
    etol = 0.01

    ns = run_nested_sampling(ns, label, etol, maxiter=maxiter)
    return ns