Ejemplo n.º 1
0
def floodTrajsWithPhotons(trajs, config, randseed):
    random.seed(randseed)
    numpy.random.seed(random.randint(0, sys.maxint))
    photcount = config.get("Photon Flooding", "photoncount")

    deltat = config.get("Monte Carlo", "deltat")
    verbose = config.get("System", "verbose")


    for key in trajs:
        traj = trajs[key]
        if verbose:
            print "Processing trajectory", key
        traj["photons"] = zeros(traj["length"])
        for ndx in range(traj["length"]):
            if verbose and ndx % 10 == 0:
                print "%d/%d\r" % (ndx, traj["length"]),

            for _ in range(photcount):
                try:
                    photon = getPhoton(traj, config, ndx)
                    endndx = int(photon.endtime / deltat)
                    if endndx != traj["length"]:
                        traj["photons"][endndx] += 1
                except ValueError:
                    pass


    return trajs
Ejemplo n.º 2
0
def floodTrajsWithPhotons(trajs, config, randseed):
    random.seed(randseed)
    numpy.random.seed(random.randint(0, sys.maxint))
    photcount = config.get("Photon Flooding", "photoncount")

    deltat = config.get("Monte Carlo", "deltat")
    verbose = config.get("System", "verbose")

    for key in trajs:
        traj = trajs[key]
        if verbose:
            print "Processing trajectory", key
        traj["photons"] = zeros(traj["length"])
        for ndx in range(traj["length"]):
            if verbose and ndx % 10 == 0:
                print "%d/%d\r" % (ndx, traj["length"]),

            for _ in range(photcount):
                try:
                    photon = getPhoton(traj, config, ndx)
                    endndx = int(photon.endtime / deltat)
                    if endndx != traj["length"]:
                        traj["photons"][endndx] += 1
                except ValueError:
                    pass

    return trajs
Ejemplo n.º 3
0
def generateBurstFromAllTraj(eprob, trajs, conf, burst):
    QD, QA, globalreject, applycorrectedcutoff = setUpBurstGeneration(conf)

    while True:
        success = False
        while not success:
            try:
                species = pickFromEnsemble(eprob)
                traj = getRandomTrajectory(trajs, species)
                photon = getPhoton(traj, conf)
                photon.checkThermal(QD, QA)
                burst.appendPhoton(photon)
                success = True
            except ValueError:
                globalreject -= 1
                if globalreject == 0:
                    raise ValueError("Too many global rejects, probably no trajectories that can fulfill the rejection criteria - giving up.")

        if burst.checkSizeReached(QD, QA, QYcorrected = applycorrectedcutoff):
            break
Ejemplo n.º 4
0
def addPhotonToBurst(conf, burst, QD, QA, traj):
    photon = getPhoton(traj, conf)
    photon.checkThermal(QD, QA)
    burst.appendPhoton(photon)