コード例 #1
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()
コード例 #2
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')
コード例 #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)