예제 #1
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_step(ctx, velocity, geoconfig, config, name):
    """Step through velocity field. Also retrieves the linspace
    from parent raster results."""
    ses = ctx.obj['session']
    vres = get_result(ses, source=velocity)
    if vres is None:
        click.echo("No matching results for ".format(velocity))
        return
    rasres = get_result(ses, id=vres.parent_id)
    if rasres is None:
        click.echo("No matching results for parent ID = {}".format(vres.parent_id))
        return

    vfield = find_data(vres, ['vector'])
    linspace = find_data(rasres, ['linspace'])
    assert vfield is not None and 'Velocity field not found'
    assert linspace is not None and 'linspace not found'

    import pixsim.step as step
    import pixsim.geometry as geometry
    pixcoll = geometry.make_pixels_center(**ctx.obj['cfg'][geoconfig])
    assert len(pixcoll) > 0
    arrays = step.step(vfield, linspace, pixcoll, **ctx.obj['cfg'][config])
    res = Result(name=name, typename='step', data=arrays, parent=vres)
    save_result(ctx, res)
예제 #2
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_boundary(ctx, config, name):
    """
    Solve boundary value problem. Takes the input msh file and solves for
    dirichlet and nuemann coefficients on the boundaries.
    """
    from pixsim.boundary import boundary
    arrays = boundary(ctx.obj['mesh_filename'], **ctx.obj['cfg'][config])
    res = Result(name=name, typename='boundary', data=arrays)
    save_result(ctx, res)
예제 #3
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_sim(ctx, response, config):
    """Entry to drift sim."""

    ses = ctx.obj['session']
    rres = get_result(ses, source=response)
    if rres is None:
        click.echo("No matching results for name = {}".format(response))
        return

    import pixsim.driftsim as dsim
    arrs = dsim.sim(rres, **ctx.obj['cfg'][config])
    res = Result(name='simwaveforms', typename='current', data=arrs)
    save_result(ctx, res)
예제 #4
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_average(ctx, name, waveforms):
    """Average waveforms across path results."""
    ses = ctx.obj['session']
    from pixsim.store import get_last_ids
    total_ids = get_last_ids(ses)['result']

    first_id, last_id, we_got = pythonify(waveforms, total_ids)
    if we_got is None:
        return

    import pixsim.current as current
    ses = ctx.obj['session']
    arrs = current.average_paths(ses, name, first_id, last_id)
    res = Result(name='average_waveforms', typename='current', data=arrs)
    save_result(ctx, res)
예제 #5
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_velocity(ctx, raster, config, name):
    """Evaluating velocity on raster"""
    ses = ctx.obj['session']
    rasres = get_result(ses, source=raster)
    if rasres is None:
        click.echo("No matching results for {}".format(raster))
        return

    potential, linspace = find_data(rasres, ['scalar', 'linspace'])
    assert(potential is not None and linspace is not None)

    import pixsim.velocity as velocity
    arrays = velocity.drift(potential, linspace, **ctx.obj['cfg'][config])
    res = Result(name=name, typename='velocity', data=arrays, parent=rasres)
    save_result(ctx, res)
예제 #6
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_raster(ctx, boundary, config, name):
    """Evaluate solution on a raster of points"""
    ses = ctx.obj['session']
    bres = None
    bres = get_result(ses, source=boundary)
    if bres is None:
        click.echo("No matching results for {}".format(boundary))
        return

    sol = find_data(bres, ['scalar'])

    from pixsim.raster import linear
    arrays = linear(ctx.obj['mesh_filename'], sol, **ctx.obj['cfg'][config])
    res = Result(name=name, typename='raster', data=arrays, parent=bres)
    save_result(ctx, res)
예제 #7
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_gen_response(ctx, config, name, waveforms, step):
    '''
    Generate response.
    '''
    ses = ctx.obj['session']
    curres = get_result(ses, id=waveforms)
    if curres is None:
        click.echo("No matching results for id = {}".format(waveforms))
        return
    stepres = get_result(ses, id=step)
    if stepres is None:
        click.echo("No matching results for id = {}".format(stepres))
        return

    import pixsim.response as rsp
    arrays = rsp.response(stepres.data, curres.data, **ctx.obj['cfg'][config])
    res = Result(name=name, typename='current', data=arrays, parent=curres)
    save_result(ctx, res)
예제 #8
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_current(ctx, step, raster, config, name):
    """Calculate the current waveforms."""
    ses = ctx.obj['session']
    sres = get_result(ses, source=step)
    if sres is None:
        click.echo("No matching results for name = {}".format(step))
        return
    rasres = get_result(ses, source=raster)
    if rasres is None:
        click.echo("No matching results for name = {}".format(raster))
        return
    assert(sres.typename == 'step' and rasres.typename == 'raster')

    efield, linspaces = find_data(rasres, ['vector', 'linspace'])
    paths = [p.data for p in sres.data if 'tuples' in p.typename]
    pnames = [p.name for p in sres.data if 'tuples' in p.typename]

    import pixsim.current as current
    arrays = current.compute(efield, linspaces, paths, pnames)
    res = Result(name=name, typename='current', data=arrays, parent=rasres)
    save_result(ctx, res)
예제 #9
0
파일: cli.py 프로젝트: hcsullivan12/pixsim
def cmd_gen_dmap(ctx, config):
    """Generate domain/pixel map from msh file"""

    import meshio
    mesh = meshio.read(ctx.obj['mesh_filename'])
    domains = dict()
    for nam, val in mesh.field_data.iteritems():
        domains[nam] = val[0]
    import pixsim.geometry as geometry
    pixcoll = geometry.make_pixels_center(**ctx.obj['cfg'][config])

    import numpy as np
    arrs = list()
    for pix in pixcoll:
        name, hdim, center, shape = pix.info()
        print name
        dom = domains[name]
        pid = int(name[5:]) # assuming name = pixel#
        arrs.append([dom, pid, center])

    arr = [Array(name='domain_map', typename='tuples', data=np.asarray(arrs))]
    res = Result(name='domain_map', typename='geometry', data=arr)
    save_result(ctx, res)