コード例 #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 ConvergenceGMRes(params, outkeys, keyinteg):
        
        Inform.Display(params['nodes'], params['itera'], 'ConvergenceGMRes')
        bar = progressbar.ProgressBar(widgets=[progressbar.Bar(), ' (', progressbar.ETA(), ') '])
        outnames = {key: DataOut(   name = outkeys[key], method = 'gm', nd = params['nodes'], 
                                    it = params['itera'], pic = params['picit']) for key in outkeys}

        type      = 'lobatto'
        integrate = True
        bfield = False
        n = Stepsize()
        omdt = np.zeros(n.st)
        xpos = np.zeros([n.st, 3])
        xvel = np.zeros([n.st, 3])

        for u in range(n.st):
            
            step = params['tend']/n.step[u]
            p = Particle(params['nodes'], n.step[u])
            
            gmres = gmres_sdc(dt = step, nodes = params['nodes'], kiter = params['itera'], pic = params['picit'], 
            nsteps = int(n.step[u]), type=type, integrate=integrate)
            x_gm, v_gm, stats = gmres.run(bfield = bfield, outnames = outnames, params = params)
            xpos[u, :] = x_gm[:, int(n.step[u])]
            xvel[u, :] = v_gm[:, int(n.step[u])]
            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)
コード例 #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 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)
コード例 #6
0
ファイル: controller.py プロジェクト: BlackCat07/Py_GMRES-SDC
    def EnergyGMRes(params, outkeys, keyinteg, numsteps):

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

        type = 'lobatto'
        integrate = True
        bfield = False
        step = params['tend'] / numsteps
        p = Particle(params['nodes'], numsteps)

        gmres = gmres_sdc(dt=step,
                          nodes=params['nodes'],
                          kiter=params['itera'],
                          pic=params['picit'],
                          nsteps=numsteps,
                          type=type,
                          integrate=integrate)
        x_gm, v_gm, stats = gmres.run(bfield=bfield,
                                      outnames=outnames,
                                      params=params)

        Inform.storeEnergy(outnames['totalenergy'].fullname, numsteps,
                           stats['energy_errors'])
コード例 #7
0
ファイル: controller.py プロジェクト: BlackCat07/Py_GMRES-SDC
    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()
コード例 #8
0
    def BrefGMRes(params, outkeys, keyinteg):
        
        Inform.Display(params['nodes'], params['itera'], 'BrefGMRes')
        bar = progressbar.ProgressBar(widgets=[progressbar.Bar(), ' (', progressbar.ETA(), ') '])
        outnames = {key: DataOut(   name = outkeys[key], method = 'gm', nd = params['nodes'], 
                                    it = params['itera'], pic = params['picit']) for key in outkeys}

        type      = 'lobatto'
        integrate = True
        bfield    = True
        n = Stepsize()

        for u in range(n.st):
            
            step = params['tend']/n.step[u]
            p = Particle(params['nodes'], n.step[u])
            
            gmres = gmres_sdc(dt = step, nodes = params['nodes'], kiter = params['itera'], pic = params['picit'], 
            nsteps = int(n.step[u]), type=type, integrate=integrate)
            x_gm, v_gm, stats = gmres.run(bfield = bfield, outnames = outnames, params = params)
            
        p.RHSeval(params, outnames['deviation'].fullname, 'BrefGMRes')