Exemplo n.º 1
0
# Testing pfset with a .pfidb file
#-----------------------------------------------------------------------------

from pathlib import Path

from parflow import Run
from parflow.tools.fs import get_absolute_path

dsingle = Run("dsingle", __file__)

dsingle.pfset(pfidb_file=get_absolute_path(
    '$PF_SRC/test/correct_output/dsingle.pfidb.ref'))


# Test pfidb
generated, _ = dsingle.write()
old_text = Path(generated).read_text()

dsingle2 = Run.from_definition(generated)
generated, _ = dsingle2.write()

new_text = Path(generated).read_text()

assert old_text and new_text
assert old_text == new_text


# Test yaml
generated, _ = dsingle.write(file_format='yaml')
old_text = Path(generated).read_text()
Exemplo n.º 2
0
#-----------------------------------------------------------------------------
# pfset: flat_map
#-----------------------------------------------------------------------------

pfset_test.pfset(
    flat_map={
        'Phase.Saturation.Type': 'VanGenuchten',
        'Phase.Saturation.GeomNames': 'domain',
    })

pfset_test.Phase.pfset(flat_map={
    'RelPerm.Type': 'VanGenuchten',
    'RelPerm.GeomNames': 'domain',
})

#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------

pfset_test.validate()
generatedFile, runFile = pfset_test.write(file_format='yaml')

# Prevent regression
with open(generatedFile) as new, open(
        get_absolute_path(
            '$PF_SRC/test/correct_output/pfset_test.yaml.ref')) as ref:
    if new.read() == ref.read():
        print('Success we have the same file')
    else:
        print('Files are different')
        sys.exit(1)
Exemplo n.º 3
0
# Set solver parameters
#-----------------------------------------------------------------------------

drich.Solver = 'Richards'
drich.Solver.MaxIter = 5

drich.Solver.Nonlinear.MaxIter = 10
drich.Solver.Nonlinear.ResidualTol = 1e-9
drich.Solver.Nonlinear.EtaChoice = 'EtaConstant'
drich.Solver.Nonlinear.EtaValue = 1e-5
drich.Solver.Nonlinear.UseJacobian = True
drich.Solver.Nonlinear.DerivativeEpsilon = 1e-2

drich.Solver.Linear.KrylovDimension = 10

drich.Solver.Linear.Preconditioner = 'MGSemi'

#-----------------------------------------------------------------------------
# Run and Unload the ParFlow output files
#-----------------------------------------------------------------------------

drich.write(file_format='yaml')

with open(get_absolute_path('drich_wells_build.yaml')) as new, \
      open(get_absolute_path('../../correct_output/drich_wells.yaml.ref')) as ref:
    if new.read() == ref.read():
        print('Success we have the same file')
    else:
        print('Files are different')
        sys.exit(1)
Exemplo n.º 4
0
import sys
from parflow import Run

yamlHierarchy = Run('hierarchical', __file__)
generatedFile, runFile = yamlHierarchy.write(file_format='yaml')

with open(generatedFile) as new, open(f'{generatedFile}.ref') as ref:
    if new.read() == ref.read():
        print('Success we have the same file')
    else:
        print('Files are different')
        sys.exit(1)
Exemplo n.º 5
0
dsingle.PhaseConcen.water.tce.Type = 'Constant'
dsingle.PhaseConcen.water.tce.GeomNames = 'concen_region'
dsingle.PhaseConcen.water.tce.Geom.concen_region.Value = 0.8

dsingle.Solver.WriteSiloSubsurfData = True
dsingle.Solver.WriteSiloPressure = True
dsingle.Solver.WriteSiloSaturation = True
dsingle.Solver.WriteSiloConcentration = True

#-----------------------------------------------------------------------------
# The Solver Impes MaxIter default value changed so to get previous
# results we need to set it back to what it was
#-----------------------------------------------------------------------------
dsingle.Solver.MaxIter = 5

#-----------------------------------------------------------------------------
# Run and Unload the ParFlow output files
#-----------------------------------------------------------------------------

generatedFile, runArg = dsingle.write()

# Prevent regression
with open(generatedFile) as new, open(
        get_absolute_path(
            '$PF_SRC/test/correct_output/dsingle.pfidb.ref')) as ref:
    if new.read() == ref.read():
        print('Success we have the same file')
    else:
        print('Files are different')
        sys.exit(1)
Exemplo n.º 6
0
ifield.Solver.PrintSubsurfData = False
ifield.Solver.PrintPressure = False
ifield.Solver.PrintSaturation = False
ifield.Solver.PrintConcentration = False

ifield.Solver.WriteSiloSubsurfData = True
ifield.Solver.WriteSiloPressure = True
ifield.Solver.WriteSiloSaturation = True
ifield.Solver.WriteSiloConcentration = True

#-----------------------------------------------------------------------------
# Ensure generated pfidb match our expectation
#-----------------------------------------------------------------------------

generatedFile, runId = ifield.write()

# Prevent regression
with open(generatedFile) as new, open(
        get_absolute_path(
            '$PF_SRC/test/correct_output/indicator_field.pfidb.ref')) as ref:
    if new.read() != ref.read():
        print('Generated PFIDB does not match our expectation')
        sys.exit(1)

#-----------------------------------------------------------------------------
# Run and Unload the ParFlow output files
#-----------------------------------------------------------------------------

ifield.dist('small_domain_indicator_field.pfb')
Exemplo n.º 7
0
washita.ComputationalGrid.NZ = 50

# Copy over the driver files
cp('$PF_SRC/test/tcl/washita/clm_input/drv_clmin.dat')
cp('$PF_SRC/test/tcl/washita/clm_input/drv_vegm.alluv.dat')
cp('$PF_SRC/test/tcl/washita/clm_input/drv_vegp.dat')

# Import the driver files
CLMImporter(washita) \
    .set_default_land_names() \
    .input_file() \
    .parameters_file() \
    .map_file('drv_vegm.alluv.dat')

# Write out the yaml file
washita.write('washita', file_format='yaml')

# Remove the driver files
rm('drv_clmin.dat')
rm('drv_vegm.alluv.dat')
rm('drv_vegp.dat')


#-----------------------------------------------------------------------------
# Make a directory for the simulation run and copy files
#-----------------------------------------------------------------------------

dir_name = get_absolute_path('.')

cp('$PF_SRC/test/tcl/washita/parflow_input/LW.slopex.pfb', dir_name)
cp('$PF_SRC/test/tcl/washita/parflow_input/LW.slopey.pfb', dir_name)
Exemplo n.º 8
0
## new solver settings for Terrain Following Grid
washita.Solver.Nonlinear.EtaChoice = 'EtaConstant'
washita.Solver.Nonlinear.EtaValue = 0.001
washita.Solver.Nonlinear.UseJacobian = True
washita.Solver.Nonlinear.DerivativeEpsilon = 1e-16
washita.Solver.Nonlinear.StepTol = 1e-30
washita.Solver.Nonlinear.Globalization = 'LineSearch'
washita.Solver.Linear.KrylovDimension = 70
washita.Solver.Linear.MaxRestarts = 2

washita.Solver.Linear.Preconditioner = 'PFMGOctree'
washita.Solver.Linear.Preconditioner.PCMatrixType = 'FullJacobian'

#-----------------------------------------------------------------------------
# Distribute CLM and ParFlow inputs
#-----------------------------------------------------------------------------

washita.dist('LW.slopex.pfb')
washita.dist('LW.slopey.pfb')
washita.dist('IndicatorFile_Gleeson.50z.pfb')
washita.dist('press.init.pfb')

#-----------------------------------------------------------------------------
# Run Simulation
#-----------------------------------------------------------------------------

# Write out the yaml file
washita.write('washita_clm_keys', file_format='yaml')

washita.run()
Exemplo n.º 9
0
# -----------------------------------------------------------------------------
key           s1      s2     s3       s4      s5      s6
Perm          0.3     0.4    0.5      0.6     0.65    -
Porosity      0.9     0.87   0.345    0.567   0.675   0.7
SpecStorage   0.567   0.76   0.2234   0.554   0.455   -
RelPerm       1.1     2.2    3.3      4.4     5.5     6.6
RelPermA      1.2     2.3    2.4      3.5     4.5     -
RelPermN      1.4     1.7    2.3      3.4     5.6     -
A             5       6      7        8       9       -
# -----------------------------------------------------------------------------
'''
soil_builder = SubsurfacePropertiesBuilder(run).load_txt_content(
    soil_properties_transpose)

print('-' * 80)
print('basic mapping')
print('-' * 80)
soil_builder.print()
print('-' * 80)
print('remap s5 to s4')
print('-' * 80)
soil_builder.assign('s5', 's4').print()
print('-' * 80)
print('remap s6 to s4 (with skip)')
print('-' * 80)
soil_builder.assign('s6', 's4').print()

soil_builder.apply()

run.write()