SIMULATION
  SIMULATION_TYPE SUBSURFACE
  PROCESS_MODELS
    SUBSURFACE_FLOW flow
      MODE HYDRATE
      OPTIONS
        WINDOW_EPSILON 1.d-1
      /
    /
    WELL_MODEL well1
      OPTIONS
        FLOW_COUPLING FULLY_IMPLICIT
        TYPE HYDROSTATIC
      END
    END
  /
END

SUBSURFACE

WELLBORE_MODEL well1
  PRINT_WELL_FILE

  WELL_GRID
    NUMBER_OF_SEGMENTS 100
    TOP_OF_HOLE    12.5d0 5.d-1  500.0d0   # [x,y,z] in meters
    BOTTOM_OF_HOLE 12.5d0 5.d-1  0.0d0   # [x,y,z] in meters
    CASING 1.d0 0.d0 0.d0 0.d0 0.d0 95@1.d0
  /

  WELL
    DIAMETER 0.16d0
    FRICTION_COEFFICIENT 1.d0
    SKIN_FACTOR 0.d0
    WELL_INDEX_MODEL PEACEMAN_3D
  /

  USE_WELL_COUPLER

END

WELL_MODEL_OUTPUT
  WELL_LIQ_PRESSURE
  WELL_GAS_PRESSURE
  WELL_LIQ_Q
  WELL_GAS_Q
END

HYDRATE
  GT_3PHASE
  WITH_GIBBS_THOMSON
  THERMAL_CONDUCTIVITY IGHCC2
  ADJUST_SOLUBILITY_WITHIN_GHSZ
  GAS CO2
END

NUMERICAL_METHODS flow

  NEWTON_SOLVER
    USE_INFINITY_NORM_CONVERGENCE
    NUMERICAL_JACOBIAN
    MINIMUM_NEWTON_ITERATIONS 2
    NO_GOVERNORS
    CHECK_SOLUTION_UPDATES
    #USE_LIMITED_CONVERGENCE_CRITERIA
    #REL_UPDATE_INF_TOL 1.d-6
    #RESIDUAL_SCALED_INF_TOL 1.d-8
    #RESIDUAL_ABS_INF_TOL 1.d-7
  END

  TIMESTEPPER FLOW
    TIMESTEP_MAXIMUM_GROWTH_FACTOR 1.25
  END

END

#=========================== discretization ===================================
GRID
  TYPE STRUCTURED CARTESIAN
  NXYZ 1 1 100 
  DXYZ
    25.d0
    1.d0
    100@5.d0
  /
END

#=========================== fluid properties =================================
FLUID_PROPERTY
  PHASE LIQUID
  DIFFUSION_COEFFICIENT 2.d-9
END

FLUID_PROPERTY
  PHASE GAS
  DIFFUSION_COEFFICIENT 2.d-5
END

#=========================== more fluid properties ============================
EOS WATER
  DENSITY IF97
  ENTHALPY IF97
  STEAM_DENSITY IF97
  STEAM_ENTHALPY IF97
  SATURATION_PRESSURE IF97
END

EOS GAS
  CO2_DATABASE co2_sw-hydrate.dat
  HENRYS_CONSTANT DEFAULT
END


#=========================== material properties ==============================
MATERIAL_PROPERTY soil1
  ID 1
  CHARACTERISTIC_CURVES default
  POROSITY 0.35
  TORTUOSITY 1.d0
  ROCK_DENSITY 2650.d0
  THERMAL_CONDUCTIVITY_DRY 2.d0 #W/m-C
  THERMAL_CONDUCTIVITY_WET 2.18d0 #W/m-C
  HEAT_CAPACITY 1000 J/kg-C
  PERMEABILITY
    PERM_ISO 1.d-13
  /
  SOIL_COMPRESSIBILITY_FUNCTION LINEAR
  SOIL_COMPRESSIBILITY 4.5d-10
  SOIL_REFERENCE_PRESSURE 1.d7
END

#=========================== characteristic curves ============================

CHARACTERISTIC_CURVES default
  SATURATION_FUNCTION VG_STOMP
    N 1.84162
    OVEN_DRIED_CAP_HEAD 102108.2d0
    ALPHA 5.d-1
    LIQUID_RESIDUAL_SATURATION 0.d0
  /
  PERMEABILITY_FUNCTION MUALEM_VG_LIQ
    PHASE LIQUID
    M 0.457
    LIQUID_RESIDUAL_SATURATION 0.3
  /
  PERMEABILITY_FUNCTION MODIFIED_COREY_GAS
    PHASE GAS
    LIQUID_RESIDUAL_SATURATION 0.3
    GAS_RESIDUAL_SATURATION 0.05
  /
END

#=========================== output options ===================================
OUTPUT
  SNAPSHOT_FILE
    TIMES y 1.d-2 1.d1 5.d1 1.d2 140.d0 150.d0 160.d0 170.d0 180.d0 190.d0 2.d2
    FORMAT TECPLOT POINT
  /
  UNFILTER_NON_STATE_VARIABLES
  
  VARIABLES
   THERMODYNAMIC_STATE
   TEMPERATURE
   LIQUID_PRESSURE
   GAS_PRESSURE
   LIQUID_SATURATION
   GAS_SATURATION
   HYDRATE_SATURATION
   ICE_SATURATION
   PRECIPITATE_SATURATION
   LIQUID_MASS_FRACTIONS
   LIQUID_MOLE_FRACTIONS
   GAS_MASS_FRACTIONS
   LIQUID_DENSITY
   GAS_DENSITY
   PERMEABILITY
   LIQUID_RELATIVE_PERMEABILITY
   GAS_RELATIVE_PERMEABILITY
   POROSITY
  /
END

#=========================== times ============================================
TIME
  FINAL_TIME 2.00000d2 y
  INITIAL_TIMESTEP_SIZE 1.d0 s #1.d-6 h
  MAXIMUM_TIMESTEP_SIZE 1.d0 y #1.d0 d #4.d-6 d
END

#=========================== regions ==========================================
REGION all
  COORDINATES
    0.d0 0.d0 0.d0
    1.d5 1.d5 1.d5
  /
END

REGION top
  FACE TOP
  COORDINATES
    0.d0 0.d0  500.d0
    25.d0 1.d0 500.d0
  /
END

REGION bottom
  FACE BOTTOM
  COORDINATES
    0.d0 0.d0  0.d0
    25.d0 1.d0 0.d0
  /
END


#=========================== flow conditions ==================================

FLOW_CONDITION initial
  TYPE
    LIQUID_PRESSURE HYDROSTATIC
    MASS_FRACTION DIRICHLET
    TEMPERATURE DIRICHLET
    SALT_MASS_FRACTION DIRICHLET
  /
  DATUM 0.d0 0.d0 500.d0
  GRADIENT
    TEMPERATURE 0.d0 0.d0 -3.d-2
  END
  LIQUID_PRESSURE 1.d7
  MASS_FRACTION 0.d0 #1.d-2
  TEMPERATURE 3.d0
  SALT_MASS_FRACTION 1.d-1
END

FLOW_CONDITION injection
  SYNC_TIMESTEP_WITH_UPDATE
  TYPE
    TEMPERATURE DIRICHLET
    RATE MASS_RATE
  /
  TEMPERATURE 20.d0
  RATE LIST
    TIME_UNITS y
    DATA_UNITS kg/y kg/y kg/y MW
    INTERPOLATION STEP
    0.d0 0.d0 5.d3 0.d0 0.d0
    1.5d2 0.d0 0.d6 0.d0 0.d0
  /
END

#=========================== condition couplers ===============================
# initial condition
INITIAL_CONDITION all
  FLOW_CONDITION initial
  REGION all
END

BOUNDARY_CONDITION top
  FLOW_CONDITION initial
  REGION top
END

WELL_COUPLER injection
  FLOW_CONDITION injection
  WELL well1
END

#=========================== stratigraphy couplers ============================
STRATA
  REGION all
  MATERIAL soil1
END

#=========================== convergence criteria  ============================
END_SUBSURFACE
