コード例 #1
0
ファイル: genlsp.py プロジェクト: noobermin/sharks
def manual_genboundary(bspec,**kw):
    kwp = sd(kw,**bspec);
    getkw = mk_getkw(kwp,outletdefaults,prefer_passed = True);
    btype = getkw("type");
    lims  = getkw('lim');
    di = dict();
    for dim,lim in zip(all_lims,lims):
        di[dim] = lim;
    if btype == 'outlet':
        model = getkw('model');
        di['label']= getkw('label');
        di['phase_velocity'] = getkw('phase_velocity');
        if model == 'none':
            ret = outlet_none_tmpl.format(**di);
        elif model == 'potential':
            di = sd(manbounds_defs,**di);
            if not test(di,'connection_rank'):
                di['connection_rank'] ='';
            else:
                di['connection_rank'] = 'connection_rank {}'.format(
                    getkw('connection_rank'));
            if not test(kwp,'voltage_measurement'):
                di['voltage_measurement'] = '';
            else:
                raise NotImplementedError("haven't got to this yet...");
            di['circuit'] = di['circuit'];
            ret = outlet_pot_tmpl.format(**di);
        elif model == 'laser':
            raise NotImplementedError("need to implement the laser...");
        else:
            raise ValueError("unknown outlet model {}".format(model));
    else:
        raise NotImplementedError("yeah...");
    return ret;
コード例 #2
0
def genregions(**kw):
    def getkw(l,scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = region_defaults[l];
        if scale:
            return [scale*i for i in ret];
        return ret;
    regsplit_dir, subdivs = getkw('region_split');
    
    nonsplits = [x for x in ['x','y','z']
                 if x != regsplit_dir ];
    limkw = [x+lims
             for x in ['x','y','z']
             for lims in ['min','max']];
    lims = {k:lim for k,lim in zip(limkw,getkw('lims'))};
    
    total_doms = getkw('domains');
    doms =  [total_doms//subdivs for i in range(subdivs)];
    doms[-1] += total_doms % subdivs;
    lmn,lmx = regsplit_dir+'min', regsplit_dir+'max';
    mn,mx = lims[lmn],lims[lmx]
    edges = [mn+i*(mx-mn)/subdivs
             for i in range(subdivs)] + [mx];
    mins = edges[:-1];
    maxs = edges[1:];
    reg = sd(lims,split=getkw("split_dir").upper+"SPLIT")
    regions = [ sd(reg,**{lmn:mn,lmx:mx,'i':i,'domains':di})
                for i,(mn,mx,di) in enumerate(zip(mins,maxs,doms)) ];
    return mkregion_str(regions);
コード例 #3
0
ファイル: genall.py プロジェクト: noobermin/sharks
def gendats(di,
            w0=w0*1e2,
            width=0.46e-4,
            L=0.043e-4,
            N0=1.08e22,
            depth=0.086e-4,
            mindensity=1e18,
            dat_xres=None,
            new=False):
    if new:
        mkpinprick = mk45_pinprick_plasma
    else:
        mkpinprick = mk45_pinprick_plasma_old
    targ_plasma, targ_neutral = mkpinprick(
        dim = [i*1e-4 for i in d['tlim']],
        N0  = N0,
        laser_radius = w0,
        width = width,
        L = L,# 43nm
        depth = depth, #chosen arbitrarily
        mindensity=mindensity);
    if not dat_xres:
        dat_xres = di['res'][0]+1;
    print("making targets for {}".format(di['pbsbase']));
    dd = sd(di, f_2D = targ_plasma, dat_xres = dat_xres);
    dat = gendat(**dd);
    savetxt(
        "{}/{}".format(di['pbsbase'],'target_plasma.dat'),
        dat);
    dd = sd(d, f_2D = targ_neutral, dat_xres = dat_xres);
    dat = gendat(**dd);
    savetxt(
        "{}/{}".format(di['pbsbase'],'target_neutral.dat'),
        dat);
コード例 #4
0
ファイル: genlsp.py プロジェクト: noobermin/sharks
def genregions(**kw):
    def getkw(l, scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = region_defaults[l]
        if scale:
            return [scale * i for i in ret]
        return ret

    regsplit_dir, subdivs = getkw("region_split")

    nonsplits = [x for x in ["x", "y", "z"] if x != regsplit_dir]
    limkw = [x + lims for x in ["x", "y", "z"] for lims in ["min", "max"]]
    lims = {k: lim for k, lim in zip(limkw, getkw("lims"))}

    total_doms = getkw("domains")
    doms = [total_doms // subdivs for i in range(subdivs)]
    doms[-1] += total_doms % subdivs
    lmn, lmx = regsplit_dir + "min", regsplit_dir + "max"
    mn, mx = lims[lmn], lims[lmx]
    edges = [mn + i * (mx - mn) / subdivs for i in range(subdivs)] + [mx]
    mins = edges[:-1]
    maxs = edges[1:]
    reg = sd(lims, split=getkw("split_dir").upper + "SPLIT")
    regions = [
        sd(reg, **{lmn: mn, lmx: mx, "i": i, "domains": di}) for i, (mn, mx, di) in enumerate(zip(mins, maxs, doms))
    ]
    return mkregion_str(regions)
コード例 #5
0
ファイル: genall.py プロジェクト: noobermin/sharks
def gendats(di,
            h = 0.2e-4,
            w = 0.66e-4,
            spacing=0.66e-4,
            width=0.45e-4,
            N0=1.08e22,
            targw=450e-7,
            datfmt="%.4e",
            dat_xres=None):
    targ_plasma = mkgrate(
        N0=N0,
        spacing=spacing,
        w=w,
        h=h);
    targ_neutral = mk45dum(
        N0=N0,
        width=targw);
    print("making targets for {}".format(di['pbsbase']));
    if not dat_xres:
        dat_xres = di['res'][0]+1;
    dd = sd(di, f_2D = targ_plasma, dat_xres = dat_xres,datfmt=datfmt);
    dat = gendat(**dd);
    savetxt(
        "{}/{}".format(di['pbsbase'],'target_plasma.dat'),
        dat);
    dd = sd(d, f_2D = targ_neutral, dat_xres = dat_xres,datfmt=datfmt);
    dat = gendat(**dd);
    savetxt(
        "{}/{}".format(di['pbsbase'],'target_neutral.dat'),
        dat);
コード例 #6
0
def mk_hpcmp_pbses(pbsbase='hotwater3d_tmpl',**kw):
    hpcmp_defpbs = sd(kw,
        pbsbase = pbsbase,
        pbsname = pbsbase+'_oakley',
        cluster = 'oakley',
        concurrents=None,
        queue = None,
        ppn = None,);
    return [
        dict(
            pbsname=pbsbase),
        dict(
            pbsname = pbsbase+'_oakley_autos',
            cluster = 'oakley',),
        hpcmp_defpbs,
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase+"_garnet",
            cluster='garnet',
            queue='standard_lw'),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase+"_garnet_sm",
            cluster='garnet',
            queue='standard_sm',
            walltime=24),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase+"_garnet_48",
            cluster="garnet",
            queue="standard_lw",
            walltime=48),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase+"_garnet_debug",
            cluster='garnet',
            queue='debug',),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase+"_armstrong",
            cluster='armstrong',
            queue='standard'),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase+"_armstrong_debug",
            cluster='armstrong',
            queue='debug'),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase+"_armstrong_48",
            cluster='armstrong',
            queue='standard',
            walltime=48),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase+"_armstrong_14",
            cluster='armstrong',
            queue='standard',
            walltime=14),
        ];
コード例 #7
0
ファイル: genpbs.py プロジェクト: asteroi/sharks
def mk_hpcmp_pbses(pbsbase='hotwater3d_tmpl', **kw):
    hpcmp_defpbs = sd(
        kw,
        pbsbase=pbsbase,
        pbsname=pbsbase + '_oakley',
        cluster='oakley',
        concurrents=None,
        queue=None,
        ppn=None,
    )
    return [
        dict(pbsname=pbsbase),
        dict(
            pbsname=pbsbase + '_oakley_autos',
            cluster='oakley',
        ),
        hpcmp_defpbs,
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet",
           cluster='garnet',
           queue='standard_lw'),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet_sm",
           cluster='garnet',
           queue='standard_sm',
           walltime=24),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet_48",
           cluster="garnet",
           queue="standard_lw",
           walltime=48),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase + "_garnet_debug",
            cluster='garnet',
            queue='debug',
        ),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong",
           cluster='armstrong',
           queue='standard'),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_debug",
           cluster='armstrong',
           queue='debug'),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_48",
           cluster='armstrong',
           queue='standard',
           walltime=48),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_14",
           cluster='armstrong',
           queue='standard',
           walltime=14),
    ]
コード例 #8
0
ファイル: genlsp.py プロジェクト: asteroi/sharks
def genregions(**kw):
    def getkw(l, scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = region_defaults[l]
        if scale:
            return [scale * i for i in ret]
        return ret

    regsplit_dir, subdivs = getkw('region_split')

    nonsplits = [x for x in ['x', 'y', 'z'] if x != regsplit_dir]
    limkw = [x + lims for x in ['x', 'y', 'z'] for lims in ['min', 'max']]
    lims = {k: lim
            for k, lim in zip(limkw, getkw('lim', scale=1e-4))}

    total_doms = getkw('domains')
    doms = [total_doms // subdivs for i in range(subdivs)]
    doms[-1] += total_doms % subdivs
    lmn, lmx = regsplit_dir + 'min', regsplit_dir + 'max'
    mn, mx = lims[lmn], lims[lmx]
    edges = [mn + i * (mx - mn) / subdivs for i in range(subdivs)] + [mx]
    split_cells = getkw(getkw("region_dom_split") + "cells")

    mins = edges[:-1]
    maxs = edges[1:]
    if test(kw, "xcells") and test(kw, "ycells") and test(kw, "zcells"):
        zcells_per_region = [kw['zcells'] // subdivs for i in range(subdivs)]
        zcells_per_region[-1] += kw['zcells'] % subdivs

        cellses = [
            kw['xcells'] * kw['ycells'] * zc
            for i, zc in enumerate(zcells_per_region)
        ]
    else:
        cellses = [None for i in range(subdivs)]
    reg = sd(lims, split=getkw("region_dom_split").upper() + "SPLIT")
    regions = [
        sd(reg, **{
            lmn: mn,
            lmx: mx,
            'i': i + 1,
            'domains': di,
            'cells': cells
        })
        for i, (mn, mx, di, cells) in enumerate(zip(mins, maxs, doms, cellses))
    ]
    return mkregion_str(regions, split_cells=split_cells)
コード例 #9
0
ファイル: genall.py プロジェクト: noobermin/sharks
def mksim(pbsbase, **d):
    print("making {}".format(pbsbase))
    myd = sd(lsp_d, **d)
    lsp = genlsp(**myd)
    pbs = genpbs(pbsbase=pbsbase)
    pbs = re.sub("../scripts/autozipper", "../../scripts/autozipper", pbs)
    output(lsp, pbs, pbsbase, dats=["sine700points.dat", myd["targetdat"]], dir=pbsbase)
コード例 #10
0
def mksim(pbsbase,**d):
    print("making {}".format(pbsbase));
    myd = sd(lsp_d, **d);
    lsp=genlsp(**myd);
    #two color hack
    if test(myd, 'relative_phase'):
        relative_phases="phase {}".format(myd['relative_phase'])
    else:
        relative_phases=''
    lasers = '''
laser
wavelength 780e-7
spotsize   2.17e-4

laser
amplitude  0.36
wavelength 390e-7
{phase}
end
'''.format(phase=relative_phases);
    if test(myd, 'two_colors'):
        lsp = re.sub(r'type *19.*','type 85',lsp);
        lsp = re.sub(r' *; *\\lambda *spotsize','',lsp);
        lsp = re.sub('.*coefficients 7.80*e-03.*$', lasers,lsp,flags=re.MULTILINE);
    pbs=genpbs(pbsbase=pbsbase,domains=myd['domains']);
    pbs = re.sub("../scripts/autozipper","../../scripts/autozipper",pbs);
    pbs = re.sub("lsp-10-xy","lsp-10-xy-multilaser",pbs);
    output(lsp,pbs,pbsbase,
           dats=["sine700points.dat", myd['targetdat']],
           dir=pbsbase);
コード例 #11
0
ファイル: genall.py プロジェクト: noobermin/sharks
def gendat3d(
        di,
        w0=w0*1e2,
        width=0.46e-4,
        L=0.043e-4,
        N0=1.08e22,
        mindensity=1e18,
        dat_xres=None,
        dat_zres=4,#works for no z variation
        fmt='%.4e'
):
    targ_neutral = mk45_pinprick_neutral3d(
        dim = [i*1e-4 for i in d['tlim']],
        N0  = N0,
        laser_radius = w0,
        width = width,
        L = L,# 43nm
        mindensity=mindensity);
    if not dat_xres:
        dat_xres = di['res'][0]+1;
    print("making targets for {}".format(di['pbsbase']));
    dd = sd(di, f_3D = targ_neutral, dat_xres = dat_xres);
    dat = gendat(dat_zres=dat_zres,datfmt=fmt,**dd);
    savetxt(
        "{}/{}".format(di['pbsbase'],di['dens_dat']),
        dat);
コード例 #12
0
ファイル: gendat.py プロジェクト: noobermin/sharks
def genonescale(**kw):
    getkw = mk_getkw(kw, onescale_defaults)
    slen = getkw("solid_len")
    xlen = getkw("xlen")
    kw1 = sd(kw, tlim=(0.0, xlen) + (0.0, 0.0, 0.0, 0.0), sdim=(xlen - slen, xlen) + (0.0, 0.0, 0.0, 0.0))
    kw1["f_1D"] = genf(**kw1)
    return gentargetdat(**kw1)
コード例 #13
0
def genoptions(**kw):
    if test(kw,"options"):
        kw = sd(kw,kw['options']);
    #quirks
    getkw_outer = mk_getkw(kw,lspdefaults);
    kw['maximum_restart_dump_time'] = getkw_outer('restart')
    def genopt(k,getkw=getkw_outer,flag=False):
        if not flag: flag = k;
        i = getkw(k);
        if re.search("_ns$",flag):
            if isvalue(i):
                i*=1e9;
            else:
                scaletuple(i,1e9);
            
        if i is None or i is ():
            return "";
        elif i is True:
            return "{} ON\n".format(flag);
        elif i is False:
            return "{} OFF\n".format(flag);
        elif isvalue(i):
            return "{} {}\n".format(flag,i);
        else:
            return "{} {} end\n".format(flag,joinspace(i));
    def genopts(opts):
        title,opts = opts;
        getkw = mk_getkw(kw,opts);
        tmpl=";;{}\n{}\n"
        all_opts = "".join([
            genopt(k,getkw) for k in sorted(opts.keys()) ]);
        return tmpl.format(title,all_opts);
    out=''.join([
        genopts(iopts)
        for iopts in [restart_opts, balance_opts,]
    ]);
    out+=options_dont_touch
    out+=''.join([
        genopts(iopts) for iopts in [kinematic_opts,dump_opts,]
    ]);

    #now we do big dumps
    kw['interval_ns'] = getkw_outer("dumpinterval");
    kw['times_ns']    = getkw_outer("dumptimes");
    kw['steps']       = getkw_outer("dumpsteps");
    def gen_dumpopt(dump,opt):
        label = "{}_dump_{}".format(dump,opt);
        if test(kw, label):
            return genopt(label);
        else:
            return genopt(opt,flag=label);
    for dump in bigdumps:
        if not getkw_outer("dump_{}".format(dump)) : continue;
        out += "dump_{}s_flag ON\n".format(dump);
        for iopt in ['interval_ns','times_ns','steps']:
            out += gen_dumpopt(dump,iopt);
    return out;
コード例 #14
0
 def mktarg(di):
     dd = sd(di,
             f_2D=mk45(dim=[i * 1e-4 for i in di['tlim']],
                       N0=1.0804e22,
                       width=0.46e-4,
                       dropcorners='round'),
             dat_xres=di['res'][0])
     dat = gendat(**dd)
     savetxt("{}/{}".format(di['pbsbase'], di['dens_dat']), dat)
コード例 #15
0
ファイル: pmovie.py プロジェクト: noobermin/lspreader
def firsthash_new(frame,**kw):
    kw['new']=True;
    kw['dupes']=None;
    hashes = genhash(frame,**kw);
    uni,counts = np.unique(hashes,return_counts=True);
    d=sd(kw,dupes=uni[counts>1],removedupes=True);
    dupei = np.in1d(hashes, d['dupes'])
    hashes[dupei] = -1
    return hashes, retd;
コード例 #16
0
ファイル: genall.py プロジェクト: noobermin/sharks
def mkscale_sim(**d):
    datf = "water-{}.dat".format(d["dat"])
    d = sd(scale_sim, **d)
    d["targetdat"] = datf
    d["description"] = "scale length sim with {}".format(d["dat"])
    if not test(d, "name"):
        name = "longl_l={}_{}".format(d["dat"], d["I"])
    else:
        name = d["name"]
    mksim(name, **d)
コード例 #17
0
def mkscale_sim(**d):
    datf = "water-{}.dat".format(d['dat'])
    d = sd(scale_sim, **d)
    d['targetdat'] = datf
    d['description'] = "scale length sim with {}".format(d['dat'])
    if not test(d, "name"):
        name = "longl_l={}_{}".format(d['dat'], d['I'])
    else:
        name = d['name']
    mksim(name, **d)
コード例 #18
0
ファイル: gendat.py プロジェクト: asteroi/sharks
def genonescale(**kw):
    getkw=mk_getkw(kw,onescale_defaults);
    slen = getkw("solid_len");
    xlen = getkw("xlen");
    kw1 = sd(
        kw,
        tlim=(0.0, xlen) + (0.0,0.0,0.0,0.0),
        sdim= (xlen-slen, xlen) + (0.0,0.0,0.0,0.0));
    kw1['f_1D']= genf(**kw1)
    return gendat(**kw1);
コード例 #19
0
ファイル: gendat.py プロジェクト: noobermin/sharks
def genonescale(**kw):
    getkw=mk_getkw(kw,onescale_defaults);
    slen = getkw("solid_len");
    xlen = getkw("xlen");
    kw1 = sd(
        kw,
        tlim=(0.0, xlen) + (0.0,0.0,0.0,0.0),
        sdim= (xlen-slen, xlen) + (0.0,0.0,0.0,0.0));
    kw1['f_1D']= genf(**kw1)
    return gendat(**kw1);
コード例 #20
0
ファイル: genall.py プロジェクト: rocketman923/sharks
def mksim(pbsbase,**d):
    print("making {}".format(pbsbase));
    myd = sd(lsp_d, **d);
    lsp=genlsp(**myd);

    #making for different servers
    pbses=dict(
        oakley=genpbs(
            pbsbase=pbsbase,
            domains=myd['domains'],
            cluster='oakley'),
        garnet_debug=genpbs(
            pbsbase=pbsbase,
            domains=myd['domains'],
            cluster='garnet',
            queue='debug'),
        garnet_debug_mem=genpbs(
            pbsbase=pbsbase,
            domains=myd['domains'],
            cluster='garnet',
            ppn=16,
            queue='debug'),
        garnet=genpbs(
            pbsbase=pbsbase,
            domains=myd['domains'],
            cluster='garnet',
            queue='standard_lw'),
        garnet_short=genpbs(
            pbsbase=pbsbase,
            domains=myd['domains'],
            cluster='garnet',
            walltime=48,
            queue='standard_lw'),
        garnet_mem=genpbs(
            pbsbase=pbsbase,
            domains=myd['domains'],
            cluster='garnet',
            ppn=16,
            queue='standard_lw'),
    );
    mkdir(pbsbase);    
    auxs = [
        "sine700points.dat", myd['targetdat'],
        "autozipper"
    ];
    for aux in auxs:
        sh.copy(aux, pbsbase);
    pbsbase = "{0}/{0}".format(pbsbase);
    with open(pbsbase+".lsp","w") as f:
        f.write(lsp);
    for pbsk in pbses:
        fname = "{}_{}.pbs".format(
            pbsbase,pbsk);
        with open(fname,"w") as f:
            f.write(pbses[pbsk]);
コード例 #21
0
ファイル: genlsp_obj.py プロジェクト: noobermin/sharks
def genregions(**kw):
    def getkw(l,scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = region_defaults[l];
        if scale:
            return [scale*i for i in ret];
        return ret;
    regsplit_dir, subdivs = getkw('region_split');
    
    nonsplits = [x for x in ['x','y','z']
                 if x != regsplit_dir ];
    limkw = [x+lims
             for x in ['x','y','z']
             for lims in ['min','max']];
    lims = {k:lim for k,lim in zip(limkw,getkw('lim',scale=1e-4))};
    
    total_doms = getkw('domains');
    doms =  [total_doms//subdivs for i in range(subdivs)];
    doms[-1] += total_doms % subdivs;
    lmn,lmx = regsplit_dir+'min', regsplit_dir+'max';
    mn,mx = lims[lmn],lims[lmx]
    edges = [mn+i*(mx-mn)/subdivs
             for i in range(subdivs)] + [mx];
    split_cells = getkw(getkw("region_dom_split")+"cells");
    
    mins = edges[:-1];
    maxs = edges[1:];
    if test(kw,"xcells") and test(kw,"ycells") and test(kw,"zcells"):
        zcells_per_region = [kw['zcells']//subdivs 
                             for i in range(subdivs)]
        zcells_per_region[-1] += kw['zcells'] % subdivs;
        
        cellses = [ kw['xcells']*kw['ycells']*zc
                    for i,zc in enumerate(zcells_per_region)];
    else:
        cellses = [None for i in range(subdivs)];
    reg = sd(lims,split=getkw("region_dom_split").upper()+"SPLIT")
    regions = [ sd(reg,**{lmn:mn,lmx:mx,'i':i+1,'domains':di,'cells':cells})
                for i,(mn,mx,di,cells) in enumerate(zip(mins,maxs,doms,cellses)) ];
    return mkregion_str(regions, split_cells=split_cells);
コード例 #22
0
def mksim(pbsbase, **d):
    print("making {}".format(pbsbase))
    myd = sd(lsp_d, **d)
    lsp = genlsp(**myd)
    pbs = genpbs(pbsbase=pbsbase)
    pbs = re.sub("../scripts/autozipper", "../../scripts/autozipper", pbs)
    output(lsp,
           pbs,
           pbsbase,
           dats=["sine700points.dat", myd['targetdat']],
           dir=pbsbase)
コード例 #23
0
ファイル: genall.py プロジェクト: noobermin/sharks
 def mktarg(di):
     dd = sd(
         di,
         f_2D = mk45(
             dim = [i*1e-4 for i in di['tlim']],
             N0    = 1.0804e22,
             width = 0.46e-4,
             dropcorners='round'));
     dat = gendat(**dd);
     savetxt(
         "{}/{}".format(di['pbsbase'],di['dens_dat']),
         dat);
コード例 #24
0
ファイル: genlsp_obj.py プロジェクト: noobermin/sharks
def genconductor_boundaries(**kw):
    getkw=mk_getkw(kw, condb_defaults);
    conductorss='';
    for I,conductor in enumerate(getkw('conductors')):
        cd = sd(condb_objdef, **conductor);
        if test(cd,'from') and test(cd,'to'):
            cd['xmin'],cd['ymin'],cd['zmin'] = cd['from']
            cd['xmax'],cd['ymax'],cd['zmax'] = cd['to']
            pass;
        else:
            outlet = cd['outlet'];
            if outlet not in all_lims:
                raise ValueError('Unknown outlet "{}"'.format(outlet));
            coords = outlet_coords(outlet,kw);
            cd['width']*=1e-4;
            cd['start']*=1e-4;
            sign = lambda outlet: 1.0 if outlet[-2:] == 'ax' else -1.0
            coords[outlet] += sign(outlet)*(cd['width'] + cd['start']);
            coords[otherside(outlet)] += sign(outlet)*cd['start'];
        conductorss += condb_tmpl.format(
            i=I+1,
            **sd(cd,**coords));
    return conductorss;
コード例 #25
0
ファイル: genall.py プロジェクト: noobermin/sharks
 def mktarg(di):
     tw = di['tlim'][1] - di['tlim'][0]
     dat_xres= int(tw/(di['lim'][1]-di['lim'][0])*di['res'][0]);
     dd = sd(
         di,
         f_2D = mkcircle(
             dim = [i*1e-4 for i in di['tlim']],
             No  = 3.34e22,
             Ni  = 0.0,
             ro  = 5e-4,
             ri  = 3e-4),
         dat_xres= dat_xres,
     );
     return gendat(**dd);
コード例 #26
0
ファイル: genall.py プロジェクト: noobermin/sharks
def gendatrot(
        di,
        w0=w0*1e2,
        width=0.46e-4,
        L=0.043e-4,
        N0=1.08e22,
        mindensity=1e18,
        spotz_width=20e-4,
        yres = 75,
        fmt='%.4e',):
    print("warning: this will only work for rot3d");
    targ_neutral = mk0_pinprick_neutral3d(
        N0  = N0,
        spotz_width=spotz_width,
        laser_radius = w0,
        width = width,
        L = L,# 43nm
        mindensity=mindensity);
    #manual hacks to save space
    #generate cell sized samples around the corners.
    # x's edge
    def getsamples(point,lims,res,ndxs = 3):
        out=np.linspace(lims[0]*1e-4,lims[1]*1e-4,res+1);
        dx = out[1] - out[0];
        out = out[ out >= point - ndxs*dx ];
        out = out[ out <= point + ndxs*dx ];
        return list(out);
    def axissamples(half_width, tlim, lim, res,ndxs=3):
        p = [ tlim[0] ] + getsamples(-half_width,lim,res,ndxs=ndxs)
        p+= [0.0] + getsamples(half_width,lim,res,ndxs=ndxs)
        p+= [ tlim[1] ];
        return np.array(p);
    x = axissamples(
        w0, di['tlim'][0:2], di['lim'][0:2], di['res'][0]);
    y = np.linspace(
        di['tlim'][2]*1e-4,di['tlim'][3]*1e-4,yres+1);
    z = axissamples(
        spotz_width/2.0,
        di['tlim'][4:6], di['lim'][4:6], di['res'][2]);
    print("making targets for {}".format(di['pbsbase']));
    X,Y,Z=np.meshgrid(x,y,z,indexing='ij');
    Q=targ_neutral(X,Y,Z)
    dd = sd(di, data3D =(x,y,z,Q), datfmt=fmt);
    dat = gendat(**dd);
    savetxt(
        "{}/{}".format(di['pbsbase'],di['dens_dat']),
        dat);
コード例 #27
0
ファイル: genlsp_species.py プロジェクト: noobermin/sharks
def genconductors(**kw):
    getkw=mk_getkw(kw, condb_defaults);
    conductorss='';
    for I,conductor in enumerate(getkw('conductors')):
        cd = sd(condb_objdef, **conductor);
        coords=dict();
        if test(cd,'outlet'):
            outlet = cd['outlet'];
            if outlet not in all_lims:
                raise ValueError('Unknown outlet "{}"'.format(outlet));
            coords = outlet_coords(outlet,kw);
            cd['width']*=1e-4;
            cd['start']*=1e-4;
            if outlet[-2:] == 'ax':
                sign = 1.0;
            else:
                sign =-1.0
            cd['type']= 'BLOCK';
            coords[outlet] += sign*(cd['width'] + cd['start']);
            coords[otherside(outlet)] += sign*cd['start'];
            cd['from'] = (coords['xmin'],coords['ymin'],coords['zmin']);
            cd['to']   = (coords['xmax'],coords['ymax'],coords['zmax']);
        conductorss += condf_tmpl.format(
            i=I+1,
            xf=cd['from'][0],yf=cd['from'][1],zf=cd['from'][2],
            **cd);
        def mk_to(cd):
            '''generate the to's'''
            return ''.join([
                condt_tmpl.format(xt=xt,yt=yt,zt=zt)
                for xt,yt,zt in cd['to'] ]);
        
        if cd['type'] == 'BLOCK':
            if type(cd['to']) == list: cd['to'] = cd['to'][0]
            conductorss += condt_tmpl.format(
                xt=cd['to'][0],yt=cd['to'][1],zt=cd['to'][2]);
        elif cd['type'] == 'PARALLELPIPED':
            conductorss += mk_to(cd);
        elif cd['type'] == 'TRILATERAL':
            conductorss += mk_to(cd);
            conductorss += 'sweep_direction {sweep_direction}\n'.format(
                **cd);
        else:
            raise ValueError(
                "Unknown conductor type '{}'".format(cd['type']));
    return conductorss;
コード例 #28
0
ファイル: genall.py プロジェクト: noobermin/sharks
def mktarg(di, No = 3.34e22, ro = 5e-4, L = 1e-4):
    tw = di['tlim'][1] - di['tlim'][0]
    dat_xres= int(tw/(di['lim'][1]-di['lim'][0])*di['res'][0]);
    dd = sd(
        di,
        f_2D = fuzzcircle(
            dim = [i*1e-4 for i in di['tlim']],
            No  = No,
            ro  = ro,
            L   = L,
            prexp=True),
        dat_xres= dat_xres,
    );
    dat = gendat(**dd);
    savetxt(
        "{}/{}".format(di['pbsbase'],di['dens_dat']),
        dat);
コード例 #29
0
ファイル: genall.py プロジェクト: noobermin/sharks
def gendatclean(
        di,
        width=0.46e-4,
        N0=1.08e22,
        fmt='%.4e',):
    targ_neutral = mk45_clean_neutral2d(
        width=width,
        N0  = N0,);
    print("making targets for {}".format(di['pbsbase']));
    dd = sd(di,
            f_2D = targ_neutral,
            dat_xres=di['res'][0]+1,
            dat_yres=di['res'][0]+1);
    dat = gendat(datfmt=fmt,**dd);
    savetxt(
        "{}/{}".format(di['pbsbase'],di['dens_dat']),
        dat);
コード例 #30
0
ファイル: genall.py プロジェクト: noobermin/sharks
        contour_quantities=('RhoN10', 'RhoN10'),
    ),
    #pmovies
    no_pmovies=True,
    #particle dumps
    dump_particle=True,
    particle_dump_interval_ns=1e-15,
);
d2 = sd(d,
        lim = (-25,25,
               -25,25,
               0,0),
        tlim = (-20,20,
                -20,20,
                0,0),
        res =(1600,
              1600,
              0),
        pbsbase='prexp2',
        region_split=('y',3),
        domains=96,
        totaltime=400e-15,
        particle_dump_interval_ns=1e-15,);
gensim(**d);
gensim(**d2);

def mktarg(di, No = 3.34e22, ro = 5e-4, L = 1e-4):
    tw = di['tlim'][1] - di['tlim'][0]
    dat_xres= int(tw/(di['lim'][1]-di['lim'][0])*di['res'][0]);
    dd = sd(
        di,
コード例 #31
0
           queue='standard',
           walltime=24),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_36",
           cluster='armstrong',
           queue='standard',
           walltime=36),
    ]
    return dd


#crazy
Es = [40, 4, 0.4, 0.04, 0.004, 4e-4]
ratio = 1.5 / 0.78
for E in Es:
    d = sd(fromenergy(E, l=50e-6, cycles=cycles), **defd)
    d.update(
        n_s=1e19,
        solid_len=50,
        expf=ratio * d['l'] / 1e-6,
        lim=(-850, 50, -800, 800, 0, 0),
        tlim=(-800, 0, -700, 700, 0, 0),
        res=(18 * 32, 32 * 32, 0),
        totaltime=d['T'] * 4.0,
        timestep=5e-15,
        description="50um laser in search of 100 MeV",
        dumpinterval=10e-15,
        #movne
        movne={'clim': (1e15, 1e19)},
    )
    mkpbsbase(d)
コード例 #32
0
def genlsp(**kw):
    def getkw(l, scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = defaults[l]
        if scale:
            return [scale * i for i in ret]
        return ret

    E0 = np.sqrt(2 * getkw('I') * 1e4 / (c * e0)) * 1e-5
    xmin, xmax, ymin, ymax, zmin, zmax = getkw('lim', scale=1e-4)
    fp = joinspace(getkw("fp", scale=1e-4))
    components = joinspace(getkw("components"))
    phases = joinspace(getkw("phases"))
    l = getkw('l') * 100.0
    if test(kw, 'resd'):
        xres, yres, zres = getkw("resd")
        kw['xcells'] = (xmax - xmin) / (l / xres)
        kw['ycells'] = (ymax - ymin) / (l / yres)
        kw['zcells'] = (zmax - zmin) / (l / zres)
    else:
        kw['xcells'], kw['ycells'], kw['zcells'] = getkw("res")
    xcells, ycells, zcells = kw['xcells'], kw['ycells'], kw['zcells']
    w0 = getkw('w') * 100.0
    T = getkw('T') * 1e9
    txmin, txmax, tymin, tymax, tzmin, tzmax = getkw('tlim', scale=1e-4)
    domains = getkw('domains')
    # we have that na~l/(pi*w), and the f-number~1/2na, thus
    # f-number ~ pi*w/2l
    fnum = np.pi * w0 / 2 / l
    totaltime = getkw('totaltime') * 1e9
    timestep = getkw('timestep') * 1e9
    couraunt = min(
        ((xmax - xmin) / xcells / c_cgs) * 1e9,
        ((ymax - ymin) / ycells / c_cgs) * 1e9,
        ((zmax - zmin) / zcells / c_cgs) * 1e9,
    )
    if timestep > couraunt:
        import sys
        sys.stderr.write("warning: timestep exceeds couraunt limit\n")
    targetdat = getkw('targetdat')
    dumpinterval = getkw('dumpinterval') * 1e9
    description = getkw('description')
    restart = getkw('restart')

    pexts = genpext(**sd(kw, species=getkw('pext_species')))
    if test(kw, "regions"):
        regions = kw['regions']
    else:
        regions = genregions(**kw)
    if not test(kw, "no_pmovies"):
        pmovies = '''
particle_movie_interval_ns {dumpinterval}
particle_movie_components Q X Y Z VX VY VZ XI YI ZI
'''.format(dumpinterval=dumpinterval)
    else:
        pmovies = ''
    restarts = "maximum_restart_dump_time {}".format(
        restart) if restart else ""
    with open("hotwater3d_tmpl.lsp") as f:
        s = f.read()
    s = s.format(
        xmin=xmin,
        xmax=xmax,
        ymin=ymin,
        ymax=ymax,
        zmin=zmin,
        zmax=zmax,
        xcells=kw['xcells'],
        ycells=kw['ycells'],
        zcells=kw['zcells'],
        l=l,
        w0=w0,
        E0=E0,
        fnum=fnum,
        targ_xmin=txmin,
        targ_xmax=txmax,
        targ_ymin=tymin,
        targ_ymax=tymax,
        targ_zmin=tzmin,
        targ_zmax=tzmax,
        fp=fp,
        pulse=T,
        components=components,
        phases=phases,
        intensity=getkw('I'),
        pmovies=pmovies,
        regions=regions,
        pexts=pexts,
        domains=domains,
        totaltime=totaltime,
        timestep=timestep,
        targetdat=targetdat,
        dumpinterval=dumpinterval,
        description=description,
        restarts=restarts,
    )
    return s
コード例 #33
0
ファイル: genall.py プロジェクト: noobermin/sharks
domains=1000;
region_split=('z',68);
pbsbase="flashic_3d";
defpbs = dict(
    pbsbase=pbsbase,
    pbsname=pbsbase+"_oakley",
    domains=domains,
    cluster='oakley',
    autozipper=False,
    queue=None,
    ppn=None,);
pbses=[
    defpbs,
    sd(
        defpbs,
        pbsname=pbsbase+"_garnet_debug",
        cluster='garnet',
        queue='debug'),
    sd(
        defpbs,
        pbsname=pbsbase+"_garnet",
        cluster='garnet',
        queue='standard_lw'),
    sd(
        defpbs,
        pbsname=pbsbase+"_garnet_short",
        cluster='garnet',
        queue='standard_lw',
        walltime=48),];
gensim(
    l = 0.8e-6,
コード例 #34
0
ファイル: genlsp.py プロジェクト: asteroi/sharks
def genoptions(**kw):
    if test(kw, "options"):
        kw = sd(kw, kw['options'])
    #quirks
    getkw_outer = mk_getkw(kw, lspdefaults, prefer_passed=True)
    kw['maximum_restart_dump_time'] = getkw_outer('restart')

    def genopt(k, getkw=getkw_outer, flag=False):
        if not flag: flag = k
        i = getkw(k)
        if re.search("_ns$", flag):
            if isvalue(i):
                i *= 1e9
            else:
                scaletuple(i, 1e9)
        if i is None or i is ():
            return ""
        elif i is True:
            return "{} ON\n".format(flag)
        elif i is False:
            return "{} OFF\n".format(flag)
        elif isvalue(i):
            return "{} {}\n".format(flag, i)
        else:
            return "{} {} end\n".format(flag, joinspace(i))

    def genopts(opts):
        title, opts = opts
        getkw = mk_getkw(kw, opts, prefer_passed=True)
        tmpl = ";;{}\n{}\n"
        all_opts = "".join([genopt(k, getkw) for k in sorted(opts.keys())])
        return tmpl.format(title, all_opts)

    out = ''.join([genopts(iopts) for iopts in [
        restart_opts,
        balance_opts,
    ]])
    out += options_dont_touch
    out += ''.join([genopts(iopts) for iopts in [
        kinematic_opts,
        dump_opts,
    ]])

    #now we do big dumps
    kw['interval_ns'] = getkw_outer("dumpinterval")
    kw['times_ns'] = getkw_outer("dumptimes")
    kw['steps'] = getkw_outer("dumpsteps")

    def gen_dumpopt(dump, opt):
        label = "{}_dump_{}".format(dump, opt)
        if test(kw, label):
            return genopt(label)
        else:
            return genopt(opt, flag=label)

    for dump in bigdumps:
        if not getkw_outer("dump_{}".format(dump)): continue
        out += "dump_{}s_flag ON\n".format(dump)
        for iopt in ['interval_ns', 'times_ns', 'steps']:
            out += gen_dumpopt(dump, iopt)
    return out
コード例 #35
0
ファイル: genlsp.py プロジェクト: noobermin/sharks
def genobjects(**kw):
    getkw=mk_getkw(kw, condb_defaults);
    ux = getkw('ux');
    objss='';
    for I,objspec in enumerate(getkw('objects')):
        coords=dict();
        #objd = sd(condb_defaults, **kw);
        objd = sd(condb_objdef, **kw);
        objd = sd(objd, **objspec);
        objd['i'] = I + 1;
        if test(objspec,'outlet'):
            outlet = objd['outlet'];
            if outlet not in all_lims:
                raise ValueError('Unknown outlet "{}"'.format(outlet));
            coords = outlet_coords(outlet,kw);
            objd['width']*=ux;
            objd['start']*=ux;
            if outlet[-2:] == 'ax':
                sign = 1.0;
            else:
                sign =-1.0
            objd['type']= 'BLOCK';
            coords[outlet] += sign*(objd['width'] + objd['start']);
            coords[otherside(outlet)] += sign*objd['start'];
            objd['crossstart']*=ux;
            otherdims = [i for i in 'xyz' if i != outlet[:-3]];
            for dim in otherdims:
                if getkw('{}cells'.format(dim)) > 0:
                    coords['{}min'.format(dim)] += objd['crossstart'];
                    coords['{}max'.format(dim)] -= objd['crossstart'];
            objd['from'] = (coords['xmin'],coords['ymin'],coords['zmin']);
            objd['to']   = (coords['xmax'],coords['ymax'],coords['zmax']);
            #objss += condf_tmpl.format(
            #    i=I+1,
            #    condon=objd['condon'],
            #    xf=objd['from'][0],yf=objd['from'][1],zf=objd['from'][2],
            #    **objd);
        def mk_to(objd):
            '''generate the to's'''
            return ''.join([
                condt_tmpl.format(xt=xt,yt=yt,zt=zt)
                for xt,yt,zt in objd['to'] ]);
        frms = ['BLOCK', 'PARALLELPIPED', 'TRILATERAL'];
        if objd['type'] == 'SOLID':
            objss += obj_solid_tmpl.format(**objd);
        elif objd['type'] in frms:
            objss += condf_tmpl.format(
                xf=objd['from'][0],yf=objd['from'][1],zf=objd['from'][2],
                **objd);
            objd = sd(condb_objdef, **objd);
            if objd['type'] == 'BLOCK':
                if type(objd['to']) != list:
                    objd['to'] = [objd['to']];
            objss += mk_to(objd);
            if objd['type'] == 'TRILATERAL':
                objss += 'sweep_direction {sweep_direction}\n'.format(
                    **objd);
        elif objd['type'] == 'CONE':
            objd = sd(obj_cone_defs, **objd);
            coordtokeysl(objd, 'base', '{}b');
            coordtokeysl(objd, 'apex', '{}ap');
            coordtokeysl(objd, 'edge', '{}ed');
            objss += obj_cone_tmpl.format(**objd);
        elif objd['type'] == 'CYLINDER' or objd['type'] == 'TORUS':
            objd = sd(obj_cyl_defs, **objd);
            objd['axis'],objd['pitch'] = objd['axis_pitch'];
            objd['azaxis'],objd['azpitch'] = objd['azimuthal_axis_pitch'];
            objd['start_angle'],objd['sweep_angle'] = objd['azimuth_range'];
            if objd['type'] == 'CYLINDER':
                coordtokeysl(objd, 'base', '{}b');
                objss += obj_cyl_tmpl.format(**objd);
            elif objd['type'] == 'TORUS':
                objd = sd(obj_torus_defs,**objd);
                coordtokeysl(objd, 'center', '{}c');
                objss += obj_torus_tmpl.format(**objd);
            else:
                raise Exception("WTFdiosjf03y2q8qencdq");
        else:
            raise ValueError(
                "Unknown object type '{}'".format(objd['type']));
    pass #end for
    return objss;
コード例 #36
0
ファイル: genlsp.py プロジェクト: asteroi/sharks
def genoutlets(**kw):
    outlet_tmpl = '''
;{side}
outlet
from {xf:e}  {yf:e} {zf:e}
to   {xt:e}  {yt:e} {zt:e}
phase_velocity 1.0
drive_model NONE'''
    laser10_tmpl = '''
;laser
outlet
from {xf:e}  {yf:e} {zf:e}
to   {xt:e}  {yt:e} {zt:e}
phase_velocity 1.0
drive_model LASER
reference_point {fp}
components {components}
phases {phases}
temporal_function {lasertfunc}
analytic_function {laserafunc}
time_delay {time_delay}
'''
    retoutlets = ''
    laserkw = kw['laseroutlet'] if test(kw, 'laseroutlet') else dict()
    laserkw = sd(kw, **laserkw)
    getkw = mk_getkw(laserkw, outletdefaults, prefer_passed=True)
    if not test(laserkw, 'nolaser'):
        retoutlets += laser10_tmpl.format(
            xf=kw['xmin'],
            xt=kw['xmin'],
            yf=kw['ymin'],
            yt=kw['ymax'],
            zf=kw['zmin'],
            zt=kw['zmax'],
            fp=joinspace(scaletuple(getkw("fp"))),
            components=joinspace(getkw("components")),
            phases=joinspace(getkw("phases")),
            lasertfunc=getkw('lasertfunc'),
            laserafunc=getkw('laserafunc'),
            time_delay=getkw('laser_time_delay'),
        )
    else:
        retoutlets += outlet_tmpl.format(
            side='front',
            xf=kw['xmin'],
            xt=kw['xmin'],
            yf=kw['ymin'],
            yt=kw['ymax'],
            zf=kw['zmin'],
            zt=kw['zmax'],
        )
    retoutlets += outlet_tmpl.format(
        side='back',
        xf=kw['xmax'],
        xt=kw['xmax'],
        yf=kw['ymin'],
        yt=kw['ymax'],
        zf=kw['zmin'],
        zt=kw['zmax'],
    )

    if kw['ycells'] > 0:
        retoutlets += outlet_tmpl.format(
            side='left',
            xf=kw['xmin'],
            xt=kw['xmax'],
            yf=kw['ymin'],
            yt=kw['ymin'],
            zf=kw['zmin'],
            zt=kw['zmax'],
        )
        retoutlets += outlet_tmpl.format(
            side='right',
            xf=kw['xmin'],
            xt=kw['xmax'],
            yf=kw['ymax'],
            yt=kw['ymax'],
            zf=kw['zmin'],
            zt=kw['zmax'],
        )
    if kw['zcells'] > 0:
        retoutlets += outlet_tmpl.format(
            side='bottom',
            xf=kw['xmin'],
            xt=kw['xmax'],
            yf=kw['ymin'],
            yt=kw['ymax'],
            zf=kw['zmin'],
            zt=kw['zmin'],
        )
        retoutlets += outlet_tmpl.format(
            side='top',
            xf=kw['xmin'],
            xt=kw['xmax'],
            yf=kw['ymin'],
            yt=kw['ymax'],
            zf=kw['zmax'],
            zt=kw['zmax'],
        )
    return retoutlets
コード例 #37
0
ファイル: genall.py プロジェクト: asteroi/sharks
domains = 1000
region_split = ('z', 68)
pbsbase = "flashic_3d"
defpbs = dict(
    pbsbase=pbsbase,
    pbsname=pbsbase + "_oakley",
    domains=domains,
    cluster='oakley',
    autozipper=False,
    queue=None,
    ppn=None,
)
pbses = [
    defpbs,
    sd(defpbs,
       pbsname=pbsbase + "_garnet_debug",
       cluster='garnet',
       queue='debug'),
    sd(defpbs,
       pbsname=pbsbase + "_garnet",
       cluster='garnet',
       queue='standard_lw'),
    sd(defpbs,
       pbsname=pbsbase + "_garnet_short",
       cluster='garnet',
       queue='standard_lw',
       walltime=48),
]
gensim(
    l=0.8e-6,
    w=2.26e-6,
    I=3e18,
コード例 #38
0
ファイル: genall.py プロジェクト: asteroi/sharks
def mksim(E, l, fn, cy, yres=20):
    scale = 1.5
    d = fromenergy(
        E,
        l=l * 1e-6,
        cycles=cycles * cy,
        l2w=l2w * fn,
    )
    d = sd(defd, **d)
    mywidth = np.ceil(width * l)
    margin = 15.0
    mymargin = np.ceil(margin)
    myedges = np.ceil(margin) + mywidth
    timestep = l * 1e-6 / c / tstep
    yres = int(np.ceil((2 * myedges) / (l / yres)))
    pbsbase = pbsfmt.format(
        l='0.8' if l == 0.78 else int(l),
        I=d['I'],
        scale=scale,
        fn=np.pi * d['w'] / 2 / d['l'],
        cs=cy,
    )
    pbses = mk_hpcmp_pbses(pbsbase=pbsbase,
                           domains=domains,
                           lspexec='lsp-10-xy')
    print("processing {}".format(pbsbase))
    #original targets
    d.update(
        pbsbase=pbsbase,
        #target
        fp='nc',
        n_s=1e23,
        solid_len=10,
        expf=scale,
        scale_with_min=True,
        long_resd=20,
        long_margin=(mymargin, mymargin),
        n_min=1e16,
        roundup_pp=True,
        # others
        lim=(0, 0, -myedges, myedges, 0, 0),
        tlim=(0, 0, -mywidth, mywidth, 0, 0),
        res=(0, yres, 0),
        timestep=timestep,
        dumpinterval=timestep * 2,
        totaltime=d['T'] * 3.5,
        description=pbsbase,
        pbses=pbses,
        domains=domains,
        region_dom_split='y',
        #movs
        movne=dict(clim=(1e16, 1e23)),
        movni=dict(clim=(1e16, 1e23)),
        movdq=dict(clim=(-1e19, 1e19), linthresh=1e15),
        movrho=dict(clim=(-1e19, 1e19), linthresh=1e15),
        dir=True,
    )
    gensim(**d)
    #scaled targets
    if np.isclose(l, 0.78): return
    scale = d['expf'] = l2L * l
    pbsbase = pbsfmt.format(l=int(l),
                            I=d['I'],
                            scale=scale,
                            fn=np.pi * d['w'] / 2 / d['l'],
                            cs=cy)
    d['pbsbase'] = pbsbase
    print("processing {}".format(pbsbase))
    d['pbses'] = mk_hpcmp_pbses(pbsbase=pbsbase,
                                domains=96,
                                lspexec='lsp-10-xy')
    if np.isclose(l, 10.0): d['n_min'] = 5e16
    #note I DO NOT remake movnes, because 1e17 is close enough.
    gensim(**d)
コード例 #39
0
ファイル: gendat.py プロジェクト: asteroi/sharks
        0, tlim[1]-tlim[0],
        0, tlim[3]-tlim[2],
        0, tlim[5]-tlim[4])

def genf(**kw):
    getkw=mk_getkw(kw,datdefaults);
    if getkw('type') == 'singlescale':
        tlim = mt(getkw('tlim'),m=getkw('unit'));
        xdim = tlim[0], tlim[1];
        return mkdecay(
            getkw('n_s'), mt(getkw('sdim'),m=getkw('unit')),
            xdim, getkw('expf')*getkw('unit'));
    else:
        raise NotImplementedError("Coming soon!");

onescale_defaults = sd(
    datdefaults,
    solid_len=10,
    xlen=27.5,
);
def genonescale(**kw):
    getkw=mk_getkw(kw,onescale_defaults);
    slen = getkw("solid_len");
    xlen = getkw("xlen");
    kw1 = sd(
        kw,
        tlim=(0.0, xlen) + (0.0,0.0,0.0,0.0),
        sdim= (xlen-slen, xlen) + (0.0,0.0,0.0,0.0));
    kw1['f_1D']= genf(**kw1)
    return gendat(**kw1);
コード例 #40
0
ファイル: gendat.py プロジェクト: asteroi/sharks
def gendats(ds,**kw):
    return [ gendat(**sd(kw, d))
             for d in ds ];
コード例 #41
0
          fp=(-5, 0, 0),
          totaltime=2e-12,
          dumpinterval=5e-16,
          timestep=5e-17,
          no_pmovies=True,
          targetdat="nopreplasma-thicker.dat",
          pext_species=(10, 11),
          description="long wavelength tnsa")

#these are simulations with longer scale length
scale_sim = sd(lsp_d,
               lim=(-50, 50, -25, 25),
               tlim=(-40, 40, -15, 15),
               res=(1000, 500),
               fp=(-4, 0, 0),
               totaltime=450e-15,
               dumpinterval=5e-16,
               timestep=5e-17,
               no_pmovies=True,
               dat="5.625um",
               pext_species=(10, 11))


def mkscale_sim(**d):
    datf = "water-{}.dat".format(d['dat'])
    d = sd(scale_sim, **d)
    d['targetdat'] = datf
    d['description'] = "scale length sim with {}".format(d['dat'])
    if not test(d, "name"):
        name = "longl_l={}_{}".format(d['dat'], d['I'])
    else:
コード例 #42
0
ファイル: genall.py プロジェクト: asteroi/sharks
    restart=23.95,
    dump_restart_flag=True,
    new_externalf=True,
    #movs
    movne=dict(ne_species='RhoN17', clim=(1e19, 1e23)),
    movrho=dict(
        clim=(-1e19, 1e19),
        linthresh=1e15,
    ),
    #pmovies
    no_pmovies=True,
    #particle dumps
    pext_species=(17, ),
)

dlim = np.array([8.6e17 / 3.33 * 1e-3, 8.6e17 / 3.33])
dlim = np.log10(dlim)
print("creating range between {} and {}".format(dlim[0], dlim[1]))
denses = np.logspace(dlim[0], dlim[1], 5)

ds = [
    sd(d,
       pbsbase="bg_{:3.1e}".format(density),
       externalf_2D=True,
       f_2D=mkbgtarg(N_bg=density, dim=[i * 1e-4 for i in d['tlim']]),
       dat_xres=500) for density in denses
]

for di in ds:
    gensim(**di)
コード例 #43
0
        clim=(-1e19, 1e19),
        linthresh=1e15,
    ),
    #pmovies
    no_pmovies=False,
    #particle dumps
    dump_particle=True,
    particle_dump_interval_ns=0.0,
    particle_dump_times_ns=(1e-4, 1.1e-4, 1.4e-4),
    pext_species=(17, 18),
)
#generating scans
hf = np.arange(2.5, 20.0, 2.5)
fps = [-1.0, 0.0, 1.0] + list(-hf) + list(hf)
peak = [
    sd(d, pbsbase='glypeak_fp={:0=+5.1f}'.format(fp), fp=(fp, 0.0, 0.0))
    for fp in fps
]

for di in peak:
    gensim(**di)
#other intensities
I3e18 = [
    sd(d,
       pbsbase='gly3e+18_fp={:0=+5.1f}'.format(fp),
       I=3e18,
       fp=(fp, 0.0, 0.0)) for fp in fps
]
I1e18 = [
    sd(d,
       pbsbase='gly1e+18_fp={:0=+5.1f}'.format(fp),
コード例 #44
0
ファイル: genlsp.py プロジェクト: noobermin/sharks
def genpext(**kw):
    def getkw(l,scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = pext_defaults[l];
        if scale:
            return [scale*i for i in ret];
        return ret;

    tmpl='''
;
extract{i}
species {species}
direction {direction}
maximum_number  1000000000
start_time {start_time}
stop_time  {stop_time}
at {position}
'''
    lims = list(getkw('lim',scale=getkw('ux')));
    lims[0] = [lims[0],0,0];
    lims[1] = [lims[1],0,0];
    lims[2] = [0,lims[2],0];
    lims[3] = [0,lims[3],0];
    lims[4] = [0,0,lims[4]];
    lims[5] = [0,0,lims[5]];
    dirs = ['X','X','Y','Y','Z','Z'];
    planes = list(zip(dirs,lims));
    if kw['zcells'] == 0:
        del planes[4:6];
    if kw['ycells'] == 0:
        del planes[2:4];
    def formatsp(sp,i):
        return [
            dict(i=i+j+1,
                 species=sp,
                 direction=d,
                 start_time=getkw('start_time'),
                 stop_time =getkw('stop_time'),
                 position  =joinspace(lim))
            for j,(d,lim) in enumerate(planes)];
    pextplanes = [
        tmpl.format(**d)
        for i,sp in enumerate(getkw('species'))
        for d in formatsp(sp,len(planes)*i)];
    ret = joinspace(pextplanes);
    if test(kw, 'extrapexts'):
        ppl = len(pextplanes);
        expext_def = dict(
            species=10,
            direction='X',
            start_time=0,
            stop_time=1,
            position=(0.0,0.0,0.0),
        );
        expexts = [];
        for p in getkw('extrapexts'):
            if test(p,'species') and p['species'] != 'all':
                expexts.append(p);
            elif test(p,'species') and type(p['species']) != str:
                expexts += [ sd(p, species = sp) for sp in p['species']];
            else:
                expexts += [ sd(p, species = sp) for sp in getkw('species') ];
        for i,ep in enumerate(expexts):
            pgetkw = mk_getkw(p, expext_def, prefer_passed = True);
            ret+=tmpl.format(
                i=ppl+i+1,
                species   = pgetkw('species'),
                direction = pgetkw('direction'),
                start_time = pgetkw('start_time'),
                stop_time = pgetkw('stop_time'),
                position  = joinspace(pgetkw('position')),);
    return ret;
コード例 #45
0
ファイル: genall.py プロジェクト: asteroi/sharks
pbsfmt='{l}um-{I:0.2e}-l={scale:0.3}um'
def mkpbsbase(d):
    l = d['l']/1e-6;
    if l > 1:
        l = int(l);
    else:
        l = '{:0.1f}'.format(l)
    d['pbsbase']=pbsfmt.format(
        l=l,I=d['I'],scale=d['expf']);

####################################
# 10um scans
####################################
defds=[]
for E in Es:
    d = sd(fromenergy(E,cycles=cycles), **defd);
    d.update(
        lim =( -50, 10, -120, 120,0,0),
        tlim=( -40,  0, -110, 110,0,0),
        res =( 60*4, 240*4, 0),
        timestep = 5e-16,
        totaltime= d['T']*3.75,
        description="10um",
        angular=True,
    );
    defds.append(d);

#10um, scale=1.5um
for d in defds:
    d['pbsbase']=pbsfmt.format(
        l=int(d['l']/1e-6),I=d['I'],scale=d['expf']);
コード例 #46
0
ファイル: genlsp.py プロジェクト: noobermin/sharks
def genboundaries(**kw):
    retboundaries = ''
    if test(kw,'manual_boundaries'):
        return '\n'.join([
            manual_genboundary(bspec,**kw)
            for bspec in kw['manual_boundaries'] ]);
    laserkw =  kw['laseroutlet'] if test(kw, 'laseroutlet') else dict();
    laserkw = sd(kw, **laserkw);
    getkw = mk_getkw(laserkw,outletdefaults,prefer_passed = True);
    lset = set();
    side_label = dict(
        xmin='front',
        xmax='back',
        ymin='left',
        ymax='right',
        zmin='bottom',
        zmax='top');
    ls = [];
    if not test(laserkw, 'multilaser') and not (test(laserkw,'nolaser') or test(laserkw,'nolaser_outlet')):
        ls = [ sd(laserkw, outlet='xmin') ];
    elif test(laserkw,'multilaser'):
        ls = kw['multilaser'];
        print("experimental multi-lasers");
        print("if you put more than one laser on a single outlet,");
        print("be sure to be using my modifications to lsp for it.");
        ls = kw['multilaser'];
    #lasers
    for l in ls:
        l = sd(laserkw, **l);
        lgetkw = mk_getkw(l, laserdefaults, prefer_passed = True);
        outlet = lgetkw('outlet');
        if outlet not in all_lims:
            raise ValueError('Unknown outlet "{}"'.format(outlet));
        lset.add(outlet);
        retboundaries += laser10_tmpl.format(
            fp = joinspace(mt(lgetkw("fp"),getkw('ux'))),
            components = joinspace(lgetkw("components")),
            phase_velocity = lgetkw('phase_velocity'),
            phases =  joinspace(lgetkw("phases")),
            lasertfunc = lgetkw('lasertfunc'),
            laserafunc = lgetkw('laserafunc'),
            time_delay = lgetkw('laser_time_delay'),
            **outlet_coords(outlet, l)
        );
    just_outlets = [i for i in all_lims if i not in lset];
    if test(kw,'freespace'):
        getkwfr = mk_getkw(
            sd(kw,**kw['freespace']),frsp_defs,prefer_passed=True);
        di=dict();
        di['model_type'] = getkwfr('model_type');
        if di['model_type'] not in ["WAVEABC","UNIAXIAL","CFSPML"]:
            raise ValueError("unrecognized model_type for freespace");
        if di['model_type']=="WAVEABC":
            di['num_of_cells'] = "";
        else:
            di['num_of_cells'] = "number_of_cells {}".format(
                getkwfr('num_of_cells'));
        keeps = getkwfr('keep_outlets');
        if keeps is None: keeps = [];
        just_outlets = [ i for i in just_outlets
                         if i in keeps ];
        if test(kw['freespace'],'frlim'):
            for dim,lim in zip(getkwfr('frlim'),all_lims):
                di[lim] = dim;
        else:
            dx = getkwfr('freesp_delta');
            keepset = lset.union(just_outlets);
            for lim in all_lims:
                di[lim] = getkw(lim);
                if lim in keepset:
                    if 'min' in lim:
                        di[lim] -= dx;
                    else:
                        di[lim] += dx;
        di['refp'] = joinspace(getkwfr('freesp_refp'));
        di['label']= getkwfr('freesp_label');
        retboundaries += freespace_tmpl.format(**di);
    #outlet boundaries which and are not removed by freespace
    for side in just_outlets:
        if laserkw[side[0]+'cells'] > 0:
            retboundaries += outlet_none_tmpl.format(
                label = side_label[side],
                phase_velocity=getkw('phase_velocity'),
                **outlet_coords(side, laserkw));
    pwbtmpl='''
planewave
from {xmin:e}  {ymin:e} {zmin:e}
to   {xmax:e}  {ymax:e} {zmax:e}
reference_point {refp}
polar_angle {polar}          
azimuthal_angle  {azimuth}
rotation_angle {rotation}
frequency {freq}
temporal_function {pwfunc}
'''
    pwbdefs = dict(
        polar=90,
        azimuth=45,
        rotation=-45,
        freq=1e3,
        pwfunc=3,
        pw_refp=[0.0,0.0,0.0],
    )
    if test(kw, 'planewave_boundary'):
        di=dict();
        pwkw = sd(kw,**kw['planewave_boundary']);
        getkwpw = mk_getkw(
            pwkw,pwbdefs,prefer_passed=True);
        if not test(pwkw, 'pwblim'):
            raise ValueError("This requires pwblim for now");
        pwlims = getkwpw('pwblim');
        for dim,lim in zip(pwlims,all_lims):
            di[lim] = dim;
        for qi in ['polar','azimuth','rotation','freq','pwfunc']:
            di[qi] = getkwpw(qi);
        di['refp'] = joinspace(getkwpw('pw_refp'));
        retboundaries+=pwbtmpl.format(**di);
    return retboundaries;
コード例 #47
0
ファイル: genall.py プロジェクト: asteroi/sharks
    lspexec='lsp-10-xy',
    fp='nc',
    #target
    n_s=1e23,
    solid_len=10,
    expf=1.5,
    #movne
    movne={'clim': (1e14, 1e21)},
    #pbs options
    autozipper=True,
    dir=True,
)
pbsfmt = '{l}um-{I:0.2e}-l={scale:0.3}um'
defds = []
for E in Es:
    d = sd(fromenergy(E), **defd)
    d.update(
        dict(
            l=10e-6,
            lim=(-50, 10, -120, 120, 0, 0),
            tlim=(-40, 0, -110, 110, 0, 0),
            res=(60 * 5, 240 * 5, 0),
            timestep=2e-16,
            totaltime=d['T'] * 3.0,
            description="10um",
            #movne
            movne={'clim': (1e14, 1e21)},
            angular=True,
        ))
    defds.append(d)
コード例 #48
0
ファイル: genall.py プロジェクト: noobermin/sharks
        dumpinterval=5e-16,
        timestep=5e-17,
        no_pmovies=True,
        targetdat="nopreplasma-thicker.dat",
        pext_species=(10, 11),
        description="long wavelength tnsa",
    )

# these are simulations with longer scale length
scale_sim = sd(
    lsp_d,
    lim=(-50, 50, -25, 25),
    tlim=(-40, 40, -15, 15),
    res=(1000, 500),
    fp=(-4, 0, 0),
    totaltime=450e-15,
    dumpinterval=5e-16,
    timestep=5e-17,
    no_pmovies=True,
    dat="5.625um",
    pext_species=(10, 11),
)


def mkscale_sim(**d):
    datf = "water-{}.dat".format(d["dat"])
    d = sd(scale_sim, **d)
    d["targetdat"] = datf
    d["description"] = "scale length sim with {}".format(d["dat"])
    if not test(d, "name"):
        name = "longl_l={}_{}".format(d["dat"], d["I"])
コード例 #49
0
    dens_dat='watercolumn.dat',
    domains=700,
    region_split=('z', 50),
    pext_species=(10, 11),
    restart=23.95,
    dump_restart_flag=True,
)

Is = [5.4e17, 1e18, 1.5e18, 3e18, 1e19]
#vanillas
for I in Is:
    pbsbase = "H2O-3d-{}".format(I)
    print(pbsbase)
    d = sd(
        lsp_d,
        I=I,
        pbsbase=pbsbase,
        pbses='defaults',
    )
    gensim(dir=True, **d)

for I in Is:
    pbsbase = "H2Osm-3d-{}".format(I)
    print(pbsbase)
    d = sd(
        lsp_d,
        I=I,
        pbsbase=pbsbase,
        pbses='defaults',
        domains=384,
        region_split=('z', 16),
    )
コード例 #50
0
ファイル: genlsp.py プロジェクト: asteroi/sharks
    def gen_dumpopt(dump, opt):
        label = "{}_dump_{}".format(dump, opt)
        if test(kw, label):
            return genopt(label)
        else:
            return genopt(opt, flag=label)

    for dump in bigdumps:
        if not getkw_outer("dump_{}".format(dump)): continue
        out += "dump_{}s_flag ON\n".format(dump)
        for iopt in ['interval_ns', 'times_ns', 'steps']:
            out += gen_dumpopt(dump, iopt)
    return out


pext_defaults = sd(lspdefaults, species=(10, ), start_time=0, stop_time=1)


def genpext(**kw):
    def getkw(l, scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = pext_defaults[l]
        if scale:
            return [scale * i for i in ret]
        return ret

    tmpl = '''
;
extract{i}
コード例 #51
0
    'fp':(0,0,0),
    'domains':48,
    'totaltime':300e-15,
    'timestep':4e-17,
    'components':(0,1,0),
    'phases':(0,0,0),
    'targetdat':'watercolumn.dat',
    'dumpinterval':2e-16,
    'description':'Hotwater in 2d',
    'pext_species':(10,),
    'restart':None,
};

pext_defaults = sd(
    defaults,
    species=(10,),
    start_time=0,
    stop_time=1);

def genpext(**kw):
    def getkw(l,scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = pext_defaults[l];
        if scale:
            return [scale*i for i in ret];
        return ret;

    tmpl='''
;
コード例 #52
0
ファイル: genlsp.py プロジェクト: noobermin/sharks
    "res": (1400, 1600),
    "tlim": (-27.5, 0, -15, 15),
    "fp": (0, 0, 0),
    "domains": 48,
    "totaltime": 300e-15,
    "timestep": 4e-17,
    "components": (0, 1, 0),
    "phases": (0, 0, 0),
    "targetdat": "watercolumn.dat",
    "dumpinterval": 2e-16,
    "description": "Hotwater in 2d",
    "pext_species": (10,),
    "restart": None,
}

pext_defaults = sd(defaults, species=(10,), start_time=0, stop_time=1)


def genpext(**kw):
    def getkw(l, scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = pext_defaults[l]
        if scale:
            return [scale * i for i in ret]
        return ret

    tmpl = """
;
extract{i}
コード例 #53
0
ファイル: genlsp.py プロジェクト: asteroi/sharks
def genlsp(**kw):
    def getkw(l, scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = lspdefaults[l]
        if scale:
            return [scale * i for i in ret]
        return ret

    def mkdims(s=''):
        return [s + 'x', s + 'y', s + 'z']

    fmtd = {}

    fmtd['options'] = genoptions(**kw)
    fmtd['E0'] = np.sqrt(2 * getkw('I') * 1e4 / (c * e0)) * 1e-5
    xmin, xmax, ymin, ymax, zmin, zmax = getkw('lim', scale=1e-4)
    kw['xmin'], kw['xmax'] = xmin, xmax
    kw['ymin'], kw['ymax'] = ymin, ymax
    kw['zmin'], kw['zmax'] = zmin, zmax
    txmin, txmax, tymin, tymax, tzmin, tzmax = getkw('tlim', scale=1e-4)
    kw['txmin'], kw['txmax'] = txmin, txmax
    kw['tymin'], kw['tymax'] = tymin, tymax
    kw['tzmin'], kw['tzmax'] = tzmin, tzmax

    l = fmtd['l'] = getkw('l') * 100.0
    if test(kw, 'resd'):
        xres, yres, zres = getkw("resd")
        kw['xcells'] = (xmax - xmin) / (l / xres) if xres > 0 else 0
        kw['ycells'] = (ymax - ymin) / (l / yres) if yres > 0 else 0
        kw['zcells'] = (zmax - zmin) / (l / zres) if zres > 0 else 0
    else:
        kw['xcells'], kw['ycells'], kw['zcells'] = getkw("res")
    xcells, ycells, zcells = kw['xcells'], kw['ycells'], kw['zcells']
    #generating non x outlets
    other_outlets = genoutlets(**kw)
    w0 = fmtd['w0'] = getkw('w') * 100.0
    fmtd['pulse'] = getkw('T') * 1e9
    #generating grid
    ygrid = zgrid = ''
    if ycells > 0:
        ygrid = ''';
ymin             {ymin:e}
ymax             {ymax:e}
y-cells          {ycells}'''.format(ymin=ymin, ymax=ymax, ycells=ycells)
    if zcells > 0:
        zgrid = ''';
zmin             {zmin:e}
zmax             {zmax:e}
z-cells          {zcells}'''.format(zmin=zmin, zmax=zmax, zcells=zcells)
    fmtd['domains'] = getkw('domains')
    # we have that na~l/(pi*w), and the f-number~1/2na, thus
    # f-number ~ pi*w/2l
    fmtd['fnum'] = np.pi * w0 / 2 / l
    fmtd['totaltime'] = getkw('totaltime') * 1e9
    fmtd['timestep'] = getkw('timestep') * 1e9
    # calculate courant
    couraunt = min(
        ((xmax - xmin) / xcells / c_cgs) * 1e9 if xcells > 0 else float('inf'),
        ((ymax - ymin) / ycells / c_cgs) * 1e9 if ycells > 0 else float('inf'),
        ((zmax - zmin) / zcells / c_cgs) * 1e9 if zcells > 0 else float('inf'),
    )
    if fmtd['timestep'] > couraunt:
        print("warning: timestep exceeds couraunt limit\n")
    #target
    kw = gendens(**kw)
    kw = gentemp(**kw)
    for species in getkw('speciesl'):
        l = 'n_' + species
        fmtd[l] = kw[l]
        l = '{}_thermalopts'.format(species)
        fmtd[l] = kw[l]
    fmtd['discrete'] = joinspace(getkw("discrete"))
    fmtd['dens_flags'] = joinspace(
        [1 if i else 0 for i in getkw("dens_flags")])
    for idim, v in zip(mkdims(), getkw('tref')):
        if v is None: v = kw['t' + idim + 'min']
        fmtd['targref' + idim] = v
    fmtd['dumpinterval'] = getkw('dumpinterval') * 1e9
    description = getkw('description')
    restart = getkw('restart')

    pexts = genpext(**sd(kw, species=getkw('pext_species')))
    if test(kw, "regions"):
        regions = kw['regions']
    else:
        regions = genregions(**kw)
    if not test(kw, "no_pmovies"):
        pmovies = '''
particle_movie_interval_ns {dumpinterval}
particle_movie_components Q X Y Z VX VY VZ XI YI ZI
'''.format(dumpinterval=fmtd['dumpinterval'])
    else:
        pmovies = ''
    fmtd['other_funcs'] = getkw('other_funcs')
    lsptemplate = getkw("lsptemplate")
    with open(lsptemplate) as f:
        s = f.read()
    s = s.format(xmin=xmin,
                 xmax=xmax,
                 ymin=ymin,
                 ymax=ymax,
                 zmin=zmin,
                 zmax=zmax,
                 xcells=xcells,
                 ycells=ycells,
                 zcells=zcells,
                 ygrid=ygrid,
                 zgrid=zgrid,
                 other_outlets=other_outlets,
                 targ_xmin=txmin,
                 targ_xmax=txmax,
                 targ_ymin=tymin,
                 targ_ymax=tymax,
                 targ_zmin=tzmin,
                 targ_zmax=tzmax,
                 intensity=getkw('I'),
                 pmovies=pmovies,
                 regions=regions,
                 pexts=pexts,
                 description=description,
                 **fmtd)
    return s
コード例 #54
0
ファイル: genlsp.py プロジェクト: noobermin/sharks
def genlsp(**kw):
    def getkw(l, scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = defaults[l]
        if scale:
            return [scale * i for i in ret]
        return ret

    intensity = getkw("I")
    E0 = np.sqrt(2 * getkw("I") * 1e4 / (c * e0)) * 1e-5
    xmin, xmax, ymin, ymax = getkw("lim", scale=1e-4)
    fp = joinspace(getkw("fp", scale=1e-4))
    components = joinspace(getkw("components"))
    phases = joinspace(getkw("phases"))
    l = getkw("l") * 100.0
    if test(kw, "resd"):
        xres, yres = getkw("resd")
        xcells = (xmax - xmin) / (l / xres)
        ycells = (ymax - ymin) / (l / yres)
    else:
        xcells, ycells = getkw("res")
    w0 = getkw("w") * 100.0
    T = getkw("T") * 1e9
    targ_xmin, targ_xmax, targ_ymin, targ_ymax = getkw("tlim", scale=1e-4)
    domains = getkw("domains")
    # we have that na~l/(pi*w), and the f-number~1/2na, thus
    # f-number ~ pi*w/2l
    fnum = np.pi * w0 / 2 / l
    totalt = getkw("totaltime") * 1e9
    timestep = getkw("timestep") * 1e9
    couraunt = min(((xmax - xmin) / xcells / c_cgs) * 1e9, ((ymax - ymin) / ycells / c_cgs) * 1e9)
    if timestep > couraunt:
        import sys

        sys.stderr.write("warning: timestep exceeds couraunt limit\n")
    pexts = genpext(**sd(kw, species=getkw("pext_species")))
    targetdat = getkw("targetdat")
    dumpinterval = getkw("dumpinterval") * 1e9
    description = getkw("description")
    restart = getkw("restart")
    if not test(kw, "no_pmovies"):
        pmovies = """
particle_movie_interval_ns {dumpinterval}
particle_movie_components Q X Y VX VY XI YI
""".format(
            dumpinterval=dumpinterval
        )
    else:
        pmovies = ""
    restarts = "maximum_restart_dump_time {}".format(restart) if restart else ""
    with open("hotwater2d_tmpl.lsp") as f:
        s = f.read()
    s = s.format(
        xmin=xmin,
        xmax=xmax,
        ymin=ymin,
        ymax=ymax,
        xcells=xcells,
        ycells=ycells,
        l=l,
        w0=w0,
        E0=E0,
        fnum=fnum,
        targ_xmin=targ_xmin,
        targ_xmax=targ_xmax,
        targ_ymin=targ_ymin,
        targ_ymax=targ_ymax,
        fp=fp,
        pulse=T,
        components=components,
        phases=phases,
        intensity=getkw("I"),
        pmovies=pmovies,
        pexts=pexts,
        domains=domains,
        totalt=totalt,
        timestep=timestep,
        targetdat=targetdat,
        dumpinterval=dumpinterval,
        description=description,
        restarts=restarts,
    )
    return s
コード例 #55
0
def genlsp(**kw):
    def getkw(l,scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = defaults[l];
        if scale:
            return [scale*i for i in ret];
        return ret;
    intensity=getkw('I');
    E0 = np.sqrt(2*getkw('I')*1e4/(c*e0))*1e-5
    xmin,xmax, ymin,ymax = getkw('lim',scale=1e-4)
    fp = joinspace(getkw("fp",scale=1e-4));
    components = joinspace(getkw("components"));
    phases = joinspace(getkw("phases"));
    l = getkw('l')*100.0
    if test(kw,'resd'):
        xres,yres = getkw("resd");
        xcells = (xmax-xmin)/(l/xres);
        ycells = (ymax-ymin)/(l/yres);
    else:
        xcells, ycells = getkw("res");
    w0 = getkw('w')*100.0;
    T  = getkw('T')*1e9;
    targ_xmin,targ_xmax, targ_ymin,targ_ymax =getkw('tlim',scale=1e-4);
    domains=getkw('domains');
    # we have that na~l/(pi*w), and the f-number~1/2na, thus
    # f-number ~ pi*w/2l
    fnum=np.pi*w0/2/l;
    totalt=getkw('totaltime')*1e9
    timestep=getkw('timestep')*1e9;
    couraunt = min(
        ((xmax-xmin)/xcells/c_cgs)*1e9,
        ((ymax-ymin)/ycells/c_cgs)*1e9)
    if timestep > couraunt:
        import sys
        sys.stderr.write("warning: timestep exceeds couraunt limit\n");
    pexts = genpext(**sd(kw,species=getkw('pext_species')));
    targetdat = getkw('targetdat');
    dumpinterval=getkw('dumpinterval')*1e9;
    description=getkw('description');
    restart = getkw('restart');
    if not test(kw,"no_pmovies"):
        pmovies ='''
particle_movie_interval_ns {dumpinterval}
particle_movie_components Q X Y VX VY XI YI
'''.format(dumpinterval=dumpinterval);
    else:
        pmovies = '';
    restarts = "maximum_restart_dump_time {}".format(restart) if restart else "";
    with open("hotwater2d_tmpl.lsp") as f:
        s=f.read();
    s=s.format(
        xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax,
        xcells=xcells,ycells=ycells,
        l=l,w0=w0,E0=E0,
        fnum=fnum,
        targ_xmin=targ_xmin, targ_xmax=targ_xmax,
        targ_ymin=targ_ymin, targ_ymax=targ_ymax,
        fp=fp,pulse=T,components=components,phases=phases,
        intensity=getkw('I'),
        pmovies=pmovies,
        pexts=pexts,
        domains=domains,
        totalt=totalt,
        timestep=timestep,
        targetdat=targetdat,
        dumpinterval=dumpinterval,
        description=description,
        restarts=restarts
    );
    return s;
コード例 #56
0
def mk_noextrapbs(d):
    dd = sd(d)
    pbsbase = dd['pbsbase']
    hpcmp_defpbs = dict(
        pbsbase=pbsbase,
        pbsname=pbsbase,
        cluster='oakley',
        autozipper=False,
        queue=None,
        ppn=None,
    )
    dd['movne'] = False
    dd['angular'] = False
    dd['pbses'] = [
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet",
           cluster='garnet',
           queue='standard_lw'),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet_20",
           cluster='garnet',
           queue='standard_sm',
           walltime=20),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet_24",
           cluster='garnet',
           queue='standard_sm',
           walltime=24),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet_short",
           cluster="garnet",
           queue="standard_lw",
           walltime=48),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet_64",
           cluster="garnet",
           queue="standard_lw",
           walltime=64),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet_72",
           cluster="garnet",
           queue="standard_lw",
           walltime=72),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_garnet_shorter",
           cluster='garnet',
           queue='standard_sm',
           walltime=12),
        sd(
            hpcmp_defpbs,
            pbsname=pbsbase + "_garnet_debug",
            cluster='garnet',
            queue='debug',
        ),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_debug",
           cluster='armstrong',
           queue='debug'),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong",
           cluster='armstrong',
           queue='standard'),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_short",
           cluster='armstrong',
           queue='standard',
           walltime=48),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_shorter",
           cluster='armstrong',
           queue='standard',
           walltime=14),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_24",
           cluster='armstrong',
           queue='standard',
           walltime=24),
        sd(hpcmp_defpbs,
           pbsname=pbsbase + "_armstrong_36",
           cluster='armstrong',
           queue='standard',
           walltime=36),
    ]
    return dd
コード例 #57
0
ファイル: genlsp.py プロジェクト: noobermin/sharks
def genlsp(**kw):
    def getkw(l,scale=None):
        if test(kw, l):
            ret = kw[l]
        else:
            ret = lspdefaults[l];
        if scale:
            return [scale*i for i in ret];
        return ret;
    def mkdims(s=''):
        return [s+'x',s+'y',s+'z'];
    ux = getkw('ux');
    fmtd = {};
    fmtd['options'] = genoptions(**kw);
    fmtd['E0'] = np.sqrt(2*getkw('I')*1e4/(c*e0))*1e-5
    spatial_lims = getkw('lim',scale=ux);
    for dim,ilim in zip(all_lims,spatial_lims):
        kw[dim]  = fmtd[dim] = ilim;
        
    if not test(kw,'tlim'):
        target_lims=spatial_lims
    else:
        target_lims=getkw('tlim',scale=ux);
    for dim,ilim in zip(all_lims,target_lims):
        kw['t'+dim] = fmtd['t'+dim] = target_lims;
        kw['targ_'+dim] = fmtd['targ_'+dim] = target_lims;
    #SI
    l=fmtd['l'] = getkw('l')*100.0
    if test(kw,'resd'):
        xres,yres,zres = getkw("resd");
        kw['xcells'] = (xmax-xmin)/(l/xres) if xres > 0 else 0;
        kw['ycells'] = (ymax-ymin)/(l/yres) if yres > 0 else 0;
        kw['zcells'] = (zmax-zmin)/(l/zres) if zres > 0 else 0;
    else:
        kw['xcells'], kw['ycells'], kw['zcells'] = getkw("res");
    xcells, ycells, zcells = kw['xcells'], kw['ycells'], kw['zcells'];
    #generating outlets
    fmtd['other_boundaries']=genboundaries(**kw);
    fmtd['objects']=genobjects(**kw);
    #dealing with conductors
    fmtd['cond_temp'] = getkw('cond_temp');
    fmtd['cond_fraction'] = getkw('cond_fraction');
    fmtd['cond_threshold']= getkw('cond_threshold');
    #others
    w0=fmtd['w0'] = getkw('w')*100.0;
    fmtd['pulse']  = getkw('T')*1e9;
    #generating grid
    xgrid,ygrid,zgrid=gengrids(**kw);
    fmtd['domains']=getkw('domains');
    # we have that na~l/(pi*w), and the f-number~1/2na, thus
    # f-number ~ pi*w/2l
    fmtd['fnum']=np.pi*w0/2/l;
    fmtd['totaltime']=getkw('totaltime')*1e9
    fmtd['timestep']=getkw('timestep')*1e9;
    # calculate courant
    if test(kw, 'xvargrid') or test(kw, 'yvargrid') or test(kw, 'zvargrid'):
        print("warning: check couraunt condition of vargrids");
    else:
        def f_(v,*arg):
            return kw[v.format(*arg)];
        #f_ = format
        dim_couraunts = [
            ( f_('{}max',dim) - f_('{}min',dim) ) / f_('{}cells',dim) / c_cgs * 1e9 if f_('{}cells',dim) > 0 else float('inf')
            for dim in 'xyz'];
        couraunt = min(*dim_couraunts);
        if fmtd['timestep'] > couraunt:
            print("warning: timestep exceeds couraunt limit\n");
    #target
    kw = gendens(**kw);
    kw = gentemp(**kw);
    fmtd['discrete']  = joinspace(getkw("discrete"));
    fmtd['dens_flags']= joinspace([
        1 if i else 0 for i in getkw("dens_flags")]);
    fmtd['gb_flags']= joinspace([
        1 if i else 0 for i in getkw("gb_flags")]);
    for dim,v in zip('xyz',getkw('tref')):
        if v is None: v = kw['t'+dim+'min'];
        fmtd['targref'+dim] = v;
    fmtd['targref'] = joinspace(mt([
        fmtd['targref'+dim] for dim in 'xyz'],getkw('ux')));
    fmtd['gammabeta'] = joinspace(getkw('gammabeta'));
    for species in getkw('speciesl'):
        def setspeciesv(fmt,defaultl,join=False,scale=False):
            l = fmt.format(species);
            if test(kw,l):
                v = kw[l];
                if scale: v=mt(v,getkw('ux'));
                if join:  v=joinspace(v);
            else:
                v = fmtd[defaultl];
            fmtd[l] = v;
        l = 'n_'+species;
        fmtd[l] = kw[l];
        l = '{}_thermalopts'.format(species);
        fmtd[l] = kw[l];
        setspeciesv('{}_discrete','discrete');
        setspeciesv('{}_targref','targref');
        setspeciesv('{}_gb','gammabeta',join=True);
        if test(kw, '{}_tlims'.format(species)):
            splim = getkw('{}_tlim'.format(species),scale=ux);
        else:
            splim = getkw('tlim',scale=ux);
        for dim,i in zip(all_lims,splim):
            fmtd['{}_{}'.format(species,dim)] = i;
    pass
    fmtd['dumpinterval']=getkw('dumpinterval')*1e9;
    description=getkw('description');
    restart = getkw('restart');

    pexts = genpext(**sd(kw,species=getkw('pext_species')));
    if test(kw, "regions"):
        regions = kw['regions'];
    else:
        regions = genregions(**kw);
    if not test(kw,"no_pmovies"):
        pmovies ='''
particle_movie_interval_ns {dumpinterval}
particle_movie_components Q X Y Z VX VY VZ XI YI ZI
'''.format(dumpinterval=fmtd['dumpinterval']);
    else:
        pmovies = '';
    fmtd['other_funcs'] = getkw('other_funcs');
    lsptemplate=getkw("lsptemplate");
    with open(lsptemplate) as f:
        s=f.read();
    s=s.format(
        xgrid=xgrid,
        ygrid=ygrid,
        zgrid=zgrid,
        intensity=getkw('I'),
        pmovies=pmovies,
        regions=regions,
        pexts=pexts,
        description=description,
        **fmtd
    );
    return s;
コード例 #58
0
ファイル: genall.py プロジェクト: asteroi/sharks
    d['dat_xres'] = 10000
    print("making targets...sit tight.")
gensim(**d)
splits = [
    #dom/reg regions
    (32, 7),
    (7 * 8, 7 * 4),
    (7 * 4, 7 * 8),
    (7 * 4, 7 * 4),
    (7 * 8, 7 * 8)
]
glyscans = [
    sd(
        d,
        pbsbase='gly_{:02d}_{:02d}'.format(i, r),
        region_split=('y', r),
        discrete=(2, 2, 1),
        domains=i * r,
    ) for i, r in splits
]


def rm_targ(i):
    if 'f_2D' in i:
        del i['f_2D']
        del i['dat_xres']
        sh.copy('glycol45/target45.dat', i['pbsbase'])
    return i


glyscans[:] = [rm_targ(i) for i in glyscans]
コード例 #59
0
ファイル: genpbs.py プロジェクト: asteroi/sharks
    ppn=48,
    walltime=inf,
    lspexec='lsp-10-3d',
    concurrents=None,
    label=None,
    mkrundir=False,
)
cluster = dict(ppn=48,
               max_walltime=9999,
               mpi='mpirun -np {}',
               max_ppn=48,
               condafile="~/conda")
clusters = {
    'ramses':
    sd(
        cluster,
        mpi='mpirun -np {} -hostfile $PBS_NODEFILE',
    ),
    'oakley':
    sd(cluster, max_ppn=12, max_walltime=96, mpi='mpiexec -n {}'),
    'garnet_standard_lw':
    sd(cluster, max_ppn=32, max_walltime=168, mpi='aprun -n {}'),
    'garnet_standard_sm':
    sd(cluster, max_ppn=32, max_walltime=24, mpi='aprun -n {}'),
    'garnet_debug':
    sd(cluster, max_ppn=32, max_walltime=1, mpi='aprun -n {}'),
    'armstrong_standard':
    sd(cluster, max_ppn=24, max_walltime=168, mpi='aprun -n {}'),
    'armstrong_debug':
    sd(cluster, max_ppn=24, max_walltime=0.5, mpi='aprun -n {}'),
}