示例#1
0
def mksim(E,l,fn,cy,
          yresd=24,long_resd=24):
    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;
    yresd = int(np.round((2*myedges) / (l / yresd)));
    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 = long_resd,
        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,yresd,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);
示例#2
0
文件: genall2.py 项目: asteroi/sharks
#!/usr/bin/env python3
from pys import sd
from genpbs import genpbs, mk_hpcmp_pbses
from gensim import gensim
import numpy as np
domains = 72 * 25
region_split = ('z', 72)
pbsbase = "flashic_3da"
pbses = mk_hpcmp_pbses(pbsbase=pbsbase, domains=domains)
gensim(
    l=0.8e-6,
    w=2.26e-6,
    I=3e18,
    T=60e-15,
    lspexec='lsp-10-3d',
    fp=(0, 0, 0),
    tref=(0, 0, 0),
    dens_flags=(True, True, True),
    lim=(-71, 9, -18, 18, -18, 18),
    tlim=(-66, 4, -13, 13, -13, 13),
    res=(80 * 10, 36 * 10, 36 * 10),
    totaltime=350e-15,
    dens_dat='flashic-20161114.dat',
    dens_type='50',
    pbsbase=pbsbase,
    description="Flash to LSP as IC in 3D",
    dumpinterval=5e-16,
    timestep=1e-16,
    domains=domains,
    region_split=region_split,
    pbses=pbses,
示例#3
0
#!/usr/bin/env python3
from pys import sd;
from genpbs import genpbs,mk_hpcmp_pbses;
from gensim import gensim;
import numpy as np;
domains=72*25;
region_split=('z',72);
pbsbase="flashic_3da";
pbses = mk_hpcmp_pbses(
    pbsbase=pbsbase,
    domains=domains);
gensim(
    l = 0.8e-6,
    w = 2.26e-6,
    I = 3e18,
    T = 60e-15,
    lspexec='lsp-10-3d',
    fp=(0,0,0),
    tref=(0,0,0),
    dens_flags=(True,True,True),
    lim =( -71, 9, -18, 18,-18, 18),
    tlim=( -66, 4, -13, 13,-13, 13),
    res =( 80*10, 36*10, 36*10),
    totaltime=350e-15,
    dens_dat='flashic-20161114.dat',
    dens_type='50',
    pbsbase=pbsbase,
    description="Flash to LSP as IC in 3D",
    dumpinterval=5e-16,
    timestep=1e-16,
    domains=domains,
示例#4
0
def gensim(**kw):
    getkw =  mk_getkw(kw,defaults);
    pbsbase=getkw("pbsbase");
    files = ["sine700points.dat"];
    if test(kw, "autozipper"):
        files.append('zipper');
    files.append('loopscript');
    #
    # target creation
    #
    if test(kw,'singlescale'):
        if type(getkw('fp')) != tuple:
            fpx = get_roundfpx(kw);
            if getkw('fp') != 'nc':
                fpx += getkw('fp');
            kw['fp'] = (fpx,0.0,0.0);
        tlim = getkw('tlim')
        kw['xlen'] = tlim[1]-tlim[0];
        dens = genonescale(**kw);
        kw['dens_dat'] = "{}um.dat".format(getkw('expf'));
        files.append((kw['dens_dat'], dens));
    elif test(kw, 'scale_with_min'):
        #this involves a single scale where we
        #pick the min. We figure out the longitudinal
        #dimensions ourselves
        if not test(kw,'long_res') and not test(kw,'long_resd'):
            raise ValueError(
                "you must supply a longitudinal resolution for scale_with_min");
        long_margin = getkw('long_margin');
        expf,n_s,n_min,slen=getkw('expf','n_s','n_min','solid_len');
        pp_len = expf*np.log(n_s/n_min);
        if test(kw,'roundup_pp'):
            pp_len = np.ceil(pp_len);
        elif test(kw,'roundup_ten_pp'):
            pp_len = np.ceil(pp_len/10) * 10;
        if type(getkw('fp')) != tuple:
            fpx = get_roundfpx(kw);
            if getkw('fp') != 'nc':
                fpx += getkw('fp');
            kw['fp'] = (fpx,0.0,0.0);
        kw['lim'] = list(getkw('lim'));
        kw['tlim'] = list(getkw('tlim'));
        kw['res']  = list(getkw('res'));
        kw['tlim'][0] = -pp_len;
        kw['tlim'][1] = slen;
        kw['lim'][0] = kw['tlim'][0] - long_margin[0];
        kw['lim'][1] = kw['tlim'][1] + long_margin[1];
        xlen = kw['lim'][1] - kw['lim'][0];
        if test(kw, 'long_res'):
            kw['res'][0]  = xlen * kw['long_res']
        elif test(kw, 'long_resd'):
            kw['res'][0]  = int(np.round(xlen / (getkw('l')*1e6 / kw['long_resd'])));
        kw['timestep'] = getkw('timestep');
        if xlen*1e-6/kw['res'][0] < c*kw['timestep']:
            print("adapting timestep...");
            kw['timestep'] = xlen*1e-6/kw['res'][0];
        dens = genonescale(xlen=kw['tlim'][1]-kw['tlim'][0], **kw);
        kw['dens_dat'] = "{:0.2f}um.dat".format(getkw('expf'));
        files.append((kw['dens_dat'], dens));
        print("from scale_with_min, generated dimensions:");
        print(take(kw,['expf','res','tlim','lim','timestep']))
    #elif test(kw,'shelf'):
    #    if type(getkw('fp')) != tuple:
            # tlim = getkw('tlim');
            # kw['xlen'] = tlim[1]-tlim[0];
            # if test(kw, 'slen'):
            # if getkw('fp') != 'nc':
            #     fpx += getkw('fp');
            # kw['fp'] = (fpx,0.0,0.0);
    elif (test(kw,'externalf_1D') and test(kw, 'f_1D')) or (test(kw,'externalf_2D') and test(kw, 'f_2D')):
        if not test(kw, 'dats'): kw['dats']=[];
        tlim = getkw('tlim');
        if not test(kw, 'new_externalf'):
            kwp = sd(kw,
                     tlim=(0, tlim[1]-tlim[0],
                           0, tlim[3]-tlim[2],
                           0, 0),
                     unit=1e-4);
        else:
            kwp = sd(kw, unit=1e-4);
        if not test(kw, 'dens_dat'):
            kw['dens_dat'] = "watercolumn.dat";
        kw['dats'] += [(kw['dens_dat'], kwp)];
    if test(kw, 'dats'):
        files.extend([
            (fname, gendat(**sd(kw,**dat)))
            for fname,dat in kw['dats']
        ]);
    #
    # movies
    #
    movs = takef(kw,['movne','movni','movdq','movrho','movE','movB','movS']);
    #yes really.
    tyf = lambda s: re.search(r"mov(\w+)",s).group(1);
    movs = { tyf(k) : movs[k]
             for k in movs
             if movs[k]};
    for movtype in sorted(movs.keys()):
        sname ='mov'+movtype;
        movd={};
        if type(kw[sname]) == dict:
            movd = sd(kw,**kw[sname]);
        if not test(movd,'n_c'):
            movd['n_c'] = nc(kw['l']);
        movd['type'] = movtype;
        movstr=gen_mov(**movd);
        #adding it to pbs
        if not test(kw, "concurrents") or kw['concurrents'] is None:
            kw['concurrents'] = [(sname,'./'+sname)];
        else:
            kw['concurrents'] += [(sname,'./'+sname)];
        files.append((sname,movstr,0o755) );
    if test(kw,'angular'):
        #adding it to pbs
        if test(kw, "concurrents") and kw['concurrents'] is not None:
            kw['concurrents'] += [('genangular','./genangular')];
        else:
            kw['concurrents'] = [('genangular','./genangular')];
        files.append('genangular');

    #
    #special subdivisions
    #
    if test(kw, "splittime"):
        totaltime = getkw("totaltime");
        # Structure of splittime 
        # [ (totaltime, dict) ]
        # Each tuple represents a slice of the restarts
        # totaltime is supposed to be the end of that time slice.
        # The dict is what enters subdiv.
        # 
        # This does very little, it just overloads totaltime and
        # sets each `lspexec` of the restarts to r. It also adds a `pre`
        # that copies the restart files, facilitated by the "setrestart"
        # script.
        #
        # We read the last totaltime over the passed keyword.
        st = getkw("splittime");
        kw['subdivs'] = [];
        for i,(itime, id) in enumerate(st):
            if id is None: id = {};
            igetkw = mk_getkw(
                sd(kw,**id),
                defaults
            );
            if i == 0:
                si = '';
            else:
                si =  '_{}'.format(i);
            kw['subdivs'].append(
                sd(id,
                   totaltime=itime,
                   lspexec  =igetkw("lspexec")+" -r ",
                   dump_restart_flag=True,
                   pbsbase=pbsbase+si,));
    subdivs = getkw("subdivs");
    if len(subdivs) == 0:
        subdivs = [kw];
    for subdiv in subdivs:
        if not subdiv: subdiv=dict();
        ikw = sd(kw,**subdiv);
        igetkw = mk_getkw(ikw, defaults);
        pbses = igetkw('pbses');
        ipbsbase = igetkw('pbsbase');
        lsp=genlsp(**ikw);
        files.append((ipbsbase+".lsp", lsp));
        if pbses is None:
            files.append((ipbsbase+".pbs",genpbs(**ikw)))
        else:
            if pbses == "defaults":
                pbses = mk_hpcmp_pbses(
                    **ikw);
            for pbs in pbses:
                files.append(
                    (pbs['pbsname']+".pbs",
                     genpbs(**sd(ikw,**pbs)))
                );
    if test(kw,'extra_files'):
        files.extend(kw['extra_files']);
    dir=getkw('dir');
    if dir == True: dir = pbsbase;
    output(dir=dir,files=files);
示例#5
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)