Ejemplo n.º 1
0
def first_order_update(CFL,
                       grid,
                       field,
                       rays,
                       system,
                       boundary_args=(),
                       source_args=()):

    # this routine performs a first-order in time explicit update

    # calculate particle velocities
    call = np.array([timer()])
    pu.get_par_acc(grid, field, rays, system)
    call = np.append(timer())
    pu.get_par_vel_terminal_velocity(grid, field, system)
    call = np.append(timer())
    pu.get_tgrow(grid, field, system)
    call = np.append(timer())

    # get timestep
    dt = pu.get_timestep(CFL, grid, field)
    call = np.append(timer())
    # growth update
    pu.size_update(grid, field, dt)
    call = np.append(timer())
    # do source update

    source.update_source(grid, field, system, dt, source_args)
    call = np.append(timer())
    # now do advection update

    pu.advection_update(grid, field, dt)
    call = np.append(timer())
    # boundary update

    boundary.update_boundary(grid, field, boundary_args)
    call = np.append(timer())
    # now do diffusion update

    pu.diffusion_update(grid, field, dt)
    call = np.append(timer())
    # boundary update

    boundary.update_boundary(grid, field, boundary_args)
    call = np.append(timer())
    return dt, call
Ejemplo n.º 2
0
def first_order_update_semi_implict(dt,
                                    grid,
                                    field,
                                    rays,
                                    system,
                                    boundary_args=(),
                                    source_args=(),
                                    getQ=None):

    # this routine performs a first-order in time explicit update with semi-implicit update of particle
    # velocity

    # calculate particle velocities
    pu.get_par_acc(grid, field, rays, system, getQ)
    pu.get_velocity_semi_implicit(grid, field, system, dt)
    pu.get_tgrow(grid, field, system)

    # growth update
    pu.size_update(grid, field, dt)

    # do source update

    source.update_source(grid, field, system, dt, source_args)

    # now do advection update

    pu.advection_update(grid, field, dt)

    # boundary update

    boundary.update_boundary(grid, field, boundary_args)

    # now do diffusion update

    pu.diffusion_update(grid, field, dt)

    # boundary update

    boundary.update_boundary(grid, field, boundary_args)

    return dt
Ejemplo n.º 3
0
def first_order_update_semi_implict_numba(dt,
                                          grid,
                                          field,
                                          rays,
                                          system,
                                          boundary_args=(),
                                          source_args=(),
                                          get_Q=None):

    # this routine performs a first-order in time explicit update with a possible semi-implicit update of particle
    # velocity - it includes parallel numba optimization for use on large grids
    # the boundary update should be fast enough in pure numpy

    # calculate particle velocities
    pu.get_par_acc_jd(grid, field, rays, system, get_Q)
    pu.get_velocity_semi_implicit_jd(grid, field, system, dt)
    pu.get_tgrow_jd(grid, field, system)

    # growth update
    pu.size_update_jd(grid, field, dt)

    # do source update

    source.update_source_jd(grid, field, rays, system, dt, source_args)

    # now do advection updates

    if (field.short_friction):

        ### just density transport
        pu.advection_update_jd(grid, field, dt)
    else:
        ## Diffusive updated is included as velocity term here - velocities computed in size update
        # as velocities have changed due to source update need to update boundries
        boundary.update_boundary(grid, field, boundary_args)
        ## compute momenta
        pu.compute_momenta_jd(grid, field)
        ## do density advenction
        pu.advection_update_jd(grid, field, dt)
        ## do momentum advection
        pu.momentum_advection_update_jd(grid, field, dt)
        ## recalculate velocities
        pu.recalculate_velocities_jd(grid, field)

    # boundary update

    if (field.short_friction):
        # do seperate diffusion update - otherwise included in advection as velocity
        boundary.update_boundary(grid, field, boundary_args)

        # now do diffusion update
        pu.diffusion_update_jd(grid, field, dt)

    # boundary update

    boundary.update_boundary(grid, field, boundary_args)

    return dt
Ejemplo n.º 4
0
ry.get_tau_grid_analytic(gd, sy)

#### Below is for testing ray-tracing scheme on analytic gas profile
#ry.do_ray_trace(fd.gas_dens*sy.kappa_star) ### using analytic gas optical depth calculation
#pu.update_tau_b_gas(fd,gd,ry,sy)
### Now initialise the initial conditions

fd.par_K[:] = Kzz

Sdot = Haze_flux

fd.par_dens[:, :, 0] = 1e-40

fd.gas_vth[1:-1, :] = 0.

bd.update_boundary(gd, fd)

kappa_bol = sy.kappa_star

Pstar = 1e-6 * 1e6
sigma_P = 0.5
a_init = 1e-7

# calculate optical depth for removal of haze production

get_tau_haze = InterpolatedUnivariateSpline(fd.gas_P[::-1, gd.NTH // 2 + 1],
                                            ry.tau_b[::-1, gd.NTH // 2 + 1])

tau_haze = get_tau_haze(Pstar + 2. * sigma_P)

fd.par_size[:] = a_init