示例#1
0
 def test_transfer_from(self):
     """transfer_from() test"""
     import mulgrids
     dx, dy, dz = [100.]*10, [120.]*8, [10.]*5
     geo = mulgrids.mulgrid().rectangular(dx, dy, dz)
     inc = t2incon()
     for blkname in geo.block_name_list:
         layername = geo.layer_name(blkname)
         colname = geo.column_name(blkname)
         pos = geo.block_centre(layername, colname)
         P = 1.e5 + 0.1 * pos[0] * pos[1] - pos[2]
         T = 240. - 1.e-4 * pos[0] * (1000. - pos[1]) + 0.1 * pos[2]
         inc[blkname] = t2blockincon(block = blkname, variable = [P, T])
     newgeo = mulgrids.mulgrid().rectangular(dx, dy, dz)
     newgeo.refine()
     newinc = t2incon()
     newinc.transfer_from(inc, geo, newgeo)
     test_blks = ['  a 1', ' bs 2', ' cb 3', '  j 4']
     for blkname in test_blks:
         val = inc[blkname].variable
         layername = geo.layer_name(blkname)
         colname = geo.column_name(blkname)
         pos = geo.block_centre(layername, colname)
         newblk = newgeo.block_name_containing_point(pos)
         newval = newinc[newblk].variable
         self.assertEqual(newval, val)
示例#2
0
def make_g_dummy(num_blocks, fname):
    bsize = 1000.0 / float(num_blocks - 1)
    geo = mulgrids.mulgrid().rectangular([bsize] * num_blocks, [1.0], [100.0],
                                         convention=2,
                                         atmos_type=2,
                                         origin=[0, 0, 0],
                                         justify='l',
                                         chars=mulgrids.ascii_uppercase)
    geo.rename_layer('A ', 'AA')
    # print geo.block_name_list
    geo.write(fname)
示例#3
0
文件: waiwera.py 项目: waiwera/credo
def t2_to_waiwera(geofilename, datfilename, incfilename =  None, basepath = None):
    """ convert tough2 model into Waiwera, saves input files and return the
    name of main input file

    TODO: maybe this should be external, and formalised more as utility
    TODO: maybe this should return ordering map, to be used in testing, eg. use
    standard geo.num_atmosphere_blocks to generate a normal one?  but this is
    not always true.
    """
    from mulgrids import mulgrid
    from t2incons import t2incon
    from t2data import t2data
    from os import getcwd, chdir
    from os.path import splitext, basename
    import json

    if basepath is None:
        basepath = getcwd()
    startpath = getcwd()
    if basepath != startpath:
        print("Changing to specified base path '%s'" % (basepath))
        os.chdir(basepath)

    geo = mulgrid(geofilename)
    dat = t2data(datfilename)

    geobase, ext = splitext(basename(geofilename))
    datbase, ext = splitext(basename(datfilename))
    mesh_filename = geobase+'.exo'
    input_filename = datbase + '.json'

    if incfilename:
        inc = t2incon(incfilename)
        incbase, ext = splitext(basename(incfilename))
        initial_filename = incbase  + '_ss.h5'
    else:
        inc = None
        initial_filename = None

    geo.write_exodusii(mesh_filename)
    print('  Mesh file %s created.' % mesh_filename)
    jsondata = dat.json(geo, mesh_filename,
                        incons = initial_filename,
                        bdy_incons = inc)
    with open(input_filename, 'w') as jf:
        json.dump(jsondata, jf, indent=2)
        print('  Input file %s created.' % input_filename)

    if basepath != startpath:
        print("Restoring initial path '%s'" % (startpath))
        os.chdir(startpath)

    return input_filename
示例#4
0
    def test_heavy_real_case(self):
        """
        TODO: should setup lighter case and check solution, this barely checks
        if it runs ok.
        """
        fault = Face3D()
        fault.read('test_geom_3dface_utils_ex.ts')
        print fault

        from mulgrids import mulgrid
        geo = mulgrid('test_geom_3dface_utils_geom.dat')

        for lay in geo.layerlist:
            print '----- layer:', lay.name, lay.centre
            fault.set_cutting_plane((0.0, 0.0, lay.centre), (0.0, 0.0, 1.0))
            line = [fault.search_line()]
示例#5
0
WAIWERA_FIELDMAP = {
    'Pressure': 'fluid_pressure',
    'Temperature': 'fluid_temperature'
}

model_dir = './run'
data_dir = './data'
t2geo_filename = os.path.join(model_dir, 'g' + model_name + '.dat')

run_name = 'run'
run_index = 0
test_fields = ["Pressure", "Temperature"]
digitised_test_fields = ["Temperature"]
digitised_simulators = ["S-Cubed"]

geo = mulgrid(t2geo_filename)
map_out_atm = range(geo.num_atmosphere_blocks, geo.num_blocks)

problem1_test = SciBenchmarkTest(model_name + "_test", nproc=num_procs)
problem1_test.description = """Model Intercomparison Study problem 1
(radial Avdonin problem)"""

obspt = 'r = 37.5 m'
obs_position = np.array([37.5, 0., -50.])
obs_blk = geo.block_name_containing_point(obs_position)
obs_cell_index = geo.block_name_index[obs_blk] - geo.num_atmosphere_blocks
max_radius = 500.

run_base_name = model_name
run_filename = run_base_name + '.json'
model_run = WaiweraModelRun(run_name,
示例#6
0
minc_production_test.description = """3-D MINC production problem, with well on deliverability,
time-dependent productivity index and steam flow limiter.
"""

obs_cell_elev = -1000.
obs_position = np.array([10., 10., obs_cell_elev])
obs_cell_index = {}
source_index = -1
t2geo_filename = {}
geo = {}

for run_index, run_name in enumerate(run_names):
    base_path = os.path.realpath(model_dir)
    run_base_name = model_name + '_' + run_name
    t2geo_filename[run_name] = os.path.join(model_dir, 'g' + run_base_name + '.dat')
    geo[run_name] = mulgrid(t2geo_filename[run_name])
    run_filename = run_base_name + '.json'
    model_run = WaiweraModelRun(run_name, run_filename,
                                fieldname_map = WAIWERA_FIELDMAP,
                                simulator = simulator,
                                basePath = base_path)
    model_run.jobParams['nproc'] = args.np
    minc_production_test.mSuite.addRun(model_run, run_name)

    obs_blk = geo[run_name].block_name_containing_point(obs_position)
    obs_cell_index[run_name] = geo[run_name].block_name_index[obs_blk] - \
                               geo[run_name].num_atmosphere_blocks

minc_production_test.setupEmptyTestCompsList()
AUTOUGH2_result = {}
示例#7
0
# ---------------------------------------------------------------------------
# setup models, load files etc.
MODELDIR = 'cc6'
t2geo_fn = "3DCoarsegrid.dat"
t2dat_fn = "CC6C001.DAT"

waiwera_fn = None
# cheated by running in windows and get the files
# waiwera_fn = 'CC6C001.json'  # AY_CYGWIN
if waiwera_fn is None:
    # this does not work in cygwin at the moment (no python vtk)
    waiwera_fn = t2_to_waiwera(t2geo_fn, t2dat_fn, basepath=MODELDIR)
# AUT2 uses dummy block for boundary condition, (atmospheric blocks here)
# get rid of them to be identical to Waiwera
geo = mulgrid(os.path.join(MODELDIR, t2geo_fn))
map_out_atm = range(geo.num_atmosphere_blocks, geo.num_blocks)

# ---------------------------------------------------------------------------
# use AUT2 to work out expected/reference results
mrun_t = T2ModelRun(
    "aut2",
    t2dat_fn,
    geo_filename=t2geo_fn,
    ordering_map=map_out_atm,
    fieldname_map=AUT2_FIELDMAP,
    # simulator='AUTOUGH2_5Dbeta',  # AY_CYGWIN
    basePath=os.path.realpath(MODELDIR))
jrunner = SimpleJobRunner()
jmeta = jrunner.submitRun(mrun_t)
mres_t = jrunner.blockResult(mrun_t, jmeta)