Esempio n. 1
0
def insert_em(grid, conf):

    #into radians
    btheta = conf.btheta/180.*np.pi
    bphi   = conf.bphi/180.*np.pi
    beta   = conf.beta

    kk = 0
    for cid in grid.get_tile_ids():
        tile = grid.get_tile(cid)
        yee = tile.get_yee(0)

        ii,jj = tile.index

        for n in range(conf.NzMesh):
            for m in range(-3, conf.NyMesh+3):
                for l in range(-3, conf.NxMesh+3):
                    # get global coordinates
                    iglob, jglob, kglob = globalIndx( (ii,jj), (l,m,n), conf)

                    yee.bx[l,m,n] = 0. #conf.binit*np.cos(btheta) 
                    yee.by[l,m,n] = 0. #conf.binit*np.sin(btheta)*np.sin(bphi)
                    yee.bz[l,m,n] = 1.0 #conf.binit*np.sin(btheta)*np.cos(bphi)   

                    yee.ex[l,m,n] = 0.0
                    yee.ey[l,m,n] = 0. #-beta*yee.bz[l,m,n]
                    yee.ez[l,m,n] = 0. #beta*yee.by[l,m,n]
Esempio n. 2
0
def insert_guide_field(grid, conf):
    binit = conf.binit  #initial B_0

    kk = 0
    for jj in range(grid.get_Ny()):
        for ii in range(grid.get_Nx()):
            if grid.get_mpi_grid(ii, jj) == grid.rank():
                c = grid.get_tile(ii, jj)
                yee = c.get_yee(0)

                for n in range(conf.NzMesh):
                    for m in range(conf.NyMesh):
                        for l in range(conf.NxMesh):

                            # get global coordinates
                            iglob, jglob, kglob = globalIndx((ii, jj),
                                                             (l, m, n), conf)

                            yee.bz[l, m, n] = binit
Esempio n. 3
0
def insert_em(grid, conf):

    kk = 0
    for tile in tiles_all(grid):
        yee = tile.get_yee(0)

        ii, jj = tile.index
        for n in range(conf.NzMesh):
            for m in range(-3, conf.NyMesh + 3):
                for l in range(-3, conf.NxMesh + 3):

                    # FIXME
                    #print("{}: ind ({},{},{})".format(grid.rank(), l,m,n))
                    # get global coordinates
                    iglob, jglob, kglob = globalIndx((ii, jj), (l, m, n), conf)

                    yee.ex[l, m, n] = 0.0
                    yee.ey[l, m, n] = 0.0
                    yee.ez[l, m, n] = 0.0

                    yee.bx[l, m, n] = 0.0
                    yee.by[l, m, n] = 0.0
                    yee.bz[l, m, n] = conf.binit
Esempio n. 4
0
def insert_em_harris_sheet(grid, conf):

    delta = conf.sheet_thickness / (2.0 * pi)  #sheet thickness incl. 2pi
    pinch_delta = conf.pinch_width / (2.0 * pi)  #pinch thickness incl. 2pi
    eta = conf.sheet_density
    beta = 0.0  #conf.beta #sheet bulk flow; NOTE: for force-free setup no flow
    sigma = conf.sigma  #magnetization

    #binit  = conf.binit
    #btheta = conf.btheta
    #bphi   = conf.bphi

    do_3D = False

    #note: if periodicx then mxhalf is 1/4 of Lx else 1/2
    mxhalf = conf.mxhalf
    myhalf = conf.myhalf
    mzhalf = conf.mzhalf

    lstripe = conf.lstripe  #FIXME del
    Lx = conf.lstripe

    binit = conf.binit  #initial B_0

    kk = 0
    for jj in range(grid.get_Ny()):
        for ii in range(grid.get_Nx()):
            if grid.get_mpi_grid(ii, jj) == grid.rank():
                c = grid.get_tile(ii, jj)
                yee = c.get_yee(0)

                for n in range(conf.NzMesh):
                    for m in range(conf.NyMesh):
                        for l in range(conf.NxMesh):

                            # get global coordinates
                            iglob, jglob, kglob = globalIndx((ii, jj),
                                                             (l, m, n), conf)

                            # trigger field modulation in z coordinate
                            if do_3D:
                                triggerz = cosh(
                                    (kglob - mzhalf) / pinch_delta)  #3D
                            else:
                                triggerz = 1.0

                            # flipping harris sheet stripe
                            if not (conf.periodicx):
                                stripetanh = tanh((iglob - mxhalf) / delta)
                            else:
                                stripetanh = tanh(
                                    Lx * sin(2. * pi * (iglob - mxhalf) / Lx) /
                                    delta / 2.0 / pi)

                            #FIXME

                            #plasma bulk velocity modulation factor;
                            #NOTE: true velocity v/c= velstripe*beta

                            #velstripe = tanh((iglob-mxhalf)/pinch_delta)/cosh((iglob-mxhalf)/pinch_delta)
                            #velstripe = tanh((iglob-mxhalf)/pinch_delta) #/(cosh((jglob-myhalf)/pinch_delta)*cosh((iglob-mxhalf)/pinch_delta))
                            velstripe = tanh((iglob - mxhalf) / pinch_delta)

                            if conf.trigger:
                                pinch_corr = (1./(cosh((jglob-myhalf)/pinch_delta) \
                                                 *cosh((iglob-mxhalf)/delta)*triggerz))

                                yee.by[l, m, n] = binit * stripetanh
                                yee.bz[l, m,
                                       n] = binit * stripetanh * (1.0 -
                                                                  pinch_corr)

                                yee.ey[l, m,
                                       n] = (-beta) * velstripe * yee.bz[l, m,
                                                                         n]

                                #drive to trigger reconnection in the middle of the box;
                                #the coefficient should be the desired ExB speed
                                yee.ez[l, m, n] = (+beta) * velstripe * yee.by[
                                    l, m,
                                    n]  #+ conf.trigger_field*abs(yee.by[l,m,n])*pinch_corr

                            else:
                                yee.by[l, m, n] = binit * stripetanh
                                yee.bz[l, m, n] = binit * np.sqrt(
                                    conf.sigma_ext)  #add guide field

                                yee.ey[l, m,
                                       n] = (-beta) * velstripe * yee.bz[l, m,
                                                                         n]
                                yee.ez[l, m,
                                       n] = (+beta) * velstripe * yee.by[l, m,
                                                                         n]

                            yee.ex[l, m, n] = 0.0

                            #hot current sheet
                            #beta_drift = sqrt(sigma)
                            beta_drift = 0.5
                            if not (conf.periodicx):
                                num_plasma = 1.0 / (cosh(
                                    (iglob - mxhalf) / delta))**2.
                            else:
                                #num_plasma = 1.0/(cosh(dstripe*lstripe*sin(2.*pi*(iglob-mxhalf)/lstripe)))**2.*stripecosh
                                num_plasma = 1.0 / cosh(
                                    Lx * sin(2. * pi * (iglob - mxhalf) / Lx) /
                                    delta / 2.0 / pi)**2.

                            gamma_drift = sqrt(1. / (1. - beta_drift**2.))
                            if conf.periodicx:
                                gamma_drift = gamma_drift * np.sign(
                                    cos(2. * pi * (iglob - mxhalf) / Lx))
                                beta_drift = sqrt(1. - 1. / gamma_drift**2
                                                  ) * np.sign(gamma_drift)

                            yee.ez[l, m, n] += beta_drift * num_plasma * binit

                # copy values to boundary cells
                try:
                    for n in range(conf.NzMesh):
                        for m in range(conf.NyMesh):
                            for l in range(conf.NxMesh):
                                c.ex_ref[l, m, n] = yee.ex[l, m, n]
                                c.ey_ref[l, m, n] = yee.ey[l, m, n]
                                c.ez_ref[l, m, n] = yee.ez[l, m, n]

                                c.bx_ref[l, m, n] = yee.bx[l, m, n]
                                c.by_ref[l, m, n] = yee.by[l, m, n]
                                c.bz_ref[l, m, n] = yee.bz[l, m, n]
                except:
                    #print("cell ({},{}) is not boundary cell".format(ii,jj))
                    pass