#!/usr/bin/env python3 ''' Create the dat file for the exponential fall-off. Usage: ./mklin.py [options] Options: --x-length=L -x L Length of x-dimension. [default: 27.5] --scale=SCALE -l SCALE Set the scale length. [default: 1.5] --solid-length=L -s L Set the solid dimensions. [default: 10] --solid=N -S N Set the solid number density. [default: 1.0e23] ''' from docopt import docopt import numpy as np from gendat import genonescale opts = docopt(__doc__, help=True) xlen = float(opts['--x-length']) solid_len = float(opts['--solid-length']) scale = float(opts['--scale']) n_s = float(opts['--solid']) print( genonescale(xlen=xlen, solid_len=solid_len, expf=scale, n_s=n_s).decode('utf-8'))
#!/usr/bin/env python3 ''' Create the dat file for the exponential fall-off. Usage: ./mklin.py [options] Options: --x-length=L -x L Length of x-dimension. [default: 27.5] --scale=SCALE -l SCALE Set the scale length. [default: 1.5] --solid-length=L -s L Set the solid dimensions. [default: 10] --solid=N -S N Set the solid number density. [default: 1.0e23] ''' from docopt import docopt import numpy as np; from gendat import genonescale opts = docopt(__doc__,help=True); xlen=float(opts['--x-length']); solid_len=float(opts['--solid-length']); scale = float(opts['--scale']); n_s = float(opts['--solid']); print(genonescale( xlen=xlen, solid_len=solid_len, expf=scale, n_s=n_s).decode('utf-8'));
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);