示例#1
0
    def BrefBrs(params, outkeys):

        Inform.Display(params['nodes'], params['itera'], 'BrefBrs')
        bar = progressbar.ProgressBar(widgets=[progressbar.Bar(), ' (', progressbar.ETA(), ') '])
        outnames = {key: DataOut(   name = outkeys[key], method = 'brs', nd = params['nodes'], 
                                    it = params['itera'], pic = params['picit']) for key in outkeys}
        
        n = Stepsize()
        
        for u in range(n.st):
            
            step = params['tend']/n.step[u]
            p = Particle(params['nodes'], n.step[u])
            p.S, p.ST, p.SQ, p.Sx, p.QQ, p.Q, p.dt, p.wi = p.GetMatrices(params['nodes'], 0.0, step)

            bar = progressbar.ProgressBar()
            for i in bar(range(int(n.step[u]))):
                
                p.SweeperNoVelUp(params['nodes'], params['itera'], p.x, p.v, p.x0, p.v0, p.x_, p.v_, 'IntegrateOff')
                p.UpdateDat(params['nodes'])
                
                if p.P.Bound(p.xend[params['nodes'] - 1, :]):
                    lastpnt = i
                    break
                
                p.GetBrefPoint(i, params['nodes'], step, p.xend, p.vend, p.dt)
        
            p.GetStanDev(step, outnames['deviation'].fullname, params)
            
        p.RHSeval(params, outnames['deviation'].fullname, 'BrefBrs')
示例#2
0
    def ConvergenceBrs(params, outkeys):
        
        Inform.Display(params['nodes'], params['itera'], 'ConvergenceBrs')
        bar = progressbar.ProgressBar(widgets=[progressbar.Bar(), ' (', progressbar.ETA(), ') '])
        outnames = {key: DataOut(   name = outkeys[key], method = 'brs', nd = params['nodes'], 
                                    it = params['itera'], pic = params['picit']) for key in outkeys}
        
        n = Stepsize()
        omdt = np.zeros(n.st)
        xpos = np.zeros([n.st, 3])

        for u in range(n.st):
            
            step = params['tend']/n.step[u]
            p = Particle(params['nodes'], n.step[u])
            p.S, p.ST, p.SQ, p.Sx, p.QQ, p.Q, p.dt, p.wi = p.GetMatrices(params['nodes'], 0.0, step)

            bar = progressbar.ProgressBar()
            for i in bar(range(int(n.step[u]))):
                
                p.SweeperNoVelUp(params['nodes'], params['itera'], p.x, p.v, p.x0, p.v0, p.x_, p.v_, 'IntegrateOff')
                p.UpdateDat(params['nodes'])
                
                if p.P.Bound(p.xend[params['nodes'] - 1, :]):
                    lastpnt = i
                    break
                    
            xpos[u, :] = p.xend[params['nodes']-1, :]
            omdt[u] = step*p.P.om_c
            
        dat = open(outnames['convergence'].fullname, "w")
        for u in range(n.st - 1):
            ierror = abs(xpos[u, 0] - xpos[u+1, 0])/abs(xpos[u, 0])
            dat.write('%e %.16e\n' % (omdt[u], ierror))
        dat.close()
示例#3
0
    def EnergyBrs(params, outkeys, numsteps):
        
        Inform.Display(params['nodes'], params['itera'], 'EnergyBrs')
        lastpnt = 0
        bar = progressbar.ProgressBar(widgets=[progressbar.Bar(), ' (', progressbar.ETA(), ') ']) 
        outnames = {key: DataOut(   name = outkeys[key], method = 'brs', nd = params['nodes'], 
                                    it = params['itera'], pic = params['picit']) for key in outkeys}
        
        step = params['tend']/numsteps
        p = Particle(params['nodes'], numsteps)
        p.S, p.ST, p.SQ, p.Sx, p.QQ, p.Q, p.dt, p.wi = p.GetMatrices(params['nodes'], 0.0, step)

        bar = progressbar.ProgressBar()
        for i in bar(range(int(numsteps))):
                
            p.SweeperNoVelUp(params['nodes'], params['itera'], p.x, p.v, p.x0, p.v0, p.x_, p.v_, 'IntegrateOff')
            p.UpdateDat(params['nodes'])
            
            p.crd[i, :] = p.xend[params['nodes'] - 1, :]
            p.vls[i, :] = p.vend[params['nodes'] - 1, :]
            p.nrg[i] = abs(p.Ekin0 - np.dot(p.vls[i,:], p.vls[i,:])/2.0)/p.Ekin0
            
            if p.P.Bound(p.xend[params['nodes'] - 1, :]):
                lastpnt = i
                break

        if lastpnt != 0:
            datanum = lastpnt
        else:
            datanum = numsteps
            
        Inform.storeEnergy(outnames['totalenergy'].fullname, datanum, p.nrg)
示例#4
0
    def ConvergenceSDC(params, outkeys, keyinteg):
        
        Inform.Display(params['nodes'], params['itera'], 'ConvergenceSDC')
        bar = progressbar.ProgressBar(widgets=[progressbar.Bar(), ' (', progressbar.ETA(), ') '])
        outnames = {key: DataOut(   name = outkeys[key], method = 'sdc', nd = params['nodes'], 
                                    it = params['itera'], pic = params['picit']) for key in outkeys}
        
        n = Stepsize()
        omdt = np.zeros(n.st)
        xpos = np.zeros([n.st, 3])

        for u in range(n.st):
            
            step = params['tend']/n.step[u]
            p = Particle(params['nodes'], n.step[u])
            p.S, p.ST, p.SQ, p.Sx, p.QQ, p.Q, p.dt, p.wi = p.GetMatrices(params['nodes'], 0.0, step)

            bar = progressbar.ProgressBar()
            for i in bar(range(int(n.step[u]))):
                
                p.Sweeper(params['nodes'], params['itera'], p.x, p.v, p.x0, p.v0, p.x_, p.v_, keyinteg)
                p.UpdateDat(params['nodes'])

                if p.P.Bound(p.xend[params['nodes'] - 1, :]):
                    lastpnt = i
                    break
                    
            xpos[u, :] = p.xend[params['nodes']-1, :]
            omdt[u] = step*p.P.om_c
        
        Inform.storePositions(outnames['positions'].fullname, n.st, xpos, omdt)
        Inform.storeConverg(outnames['convergence'].fullname, n.st - 1, xpos, omdt)
示例#5
0
    def Trajectory(params, outkeys, keyinteg, numsteps):

        Inform.Display(params['nodes'], params['itera'], 'Trajectory')
        lastpnt = 0
        bar = progressbar.ProgressBar(
            widgets=[progressbar.Bar(), ' (',
                     progressbar.ETA(), ') '])
        outnames = {
            key: DataOut(name=outkeys[key],
                         method='sdc',
                         nd=params['nodes'],
                         it=params['itera'],
                         pic=params['picit'])
            for key in outkeys
        }

        step = params['tend'] / numsteps
        p = Particle(params['nodes'], numsteps)
        p.S, p.ST, p.SQ, p.Sx, p.QQ, p.Q, p.dt, p.wi = p.GetMatrices(
            params['nodes'], 0.0, step)

        bar = progressbar.ProgressBar()
        for i in bar(range(int(numsteps))):

            p.Sweeper(params['nodes'], params['itera'], p.x, p.v, p.x0, p.v0,
                      p.x_, p.v_, keyinteg)
            p.UpdateDat(params['nodes'])
            p.crd[i, :] = p.xend[params['nodes'] - 1, :]
            p.vls[i, :] = p.vend[params['nodes'] - 1, :]

            p.mu[i] = (p.vmod**2 - (p.vmod * p.phi)**2) / p.P.Bmod(
                p.xend[params['nodes'] - 1, :])

            if p.P.Bound(p.xend[params['nodes'] - 1, :]):
                lastpnt = i
                break

        if lastpnt != 0:
            datanum = lastpnt
        else:
            datanum = numsteps

        dat = open(outnames['trajectory'].fullname, "w")
        for u in range(datanum):
            if ((u + 1) % 100) == 0:
                dat.write('%e %e %e\n' %
                          (p.crd[u, 0], p.crd[u, 1], p.crd[u, 2]))
        dat.close()