Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

scrollbar

For the initial conditions of water level, we will use some measurements at the start time of simulation. Since the information is only available at a few locations, we will interpolate those values to the rest of points within the enclosing polygon. Finally, we will assign a default value to the locations which have not been interpolated.

To begin with, we will import the measured data contained in the file measuredWaterLevelFM.csv, and will store that data in the list measuredWaterLevelsWe will read the water levels at the center of each cell from a plain text comma separated values file (initialWaterLevelFM.csv) into the initialWaterLevels list.

Code Block
languagepy
titleSet intial confitionsImport water level data
# add initial conditions 
import csv

initialWaterLevelsmeasuredWaterLevels = []

with open(r"D:\Workshop\Datadata\initialWaterLevelFMmeasuredWaterLevelFM.csv") as csvfile: 
    lines = csv.reader(csvfile, delimiter=',')
    headers = lines.next()
    for line in lines:
        initialWaterLevelsmeasuredWaterLevels.append(map(float(, line[0]))

Once loaded, we set add the sample points to the initial values water level coverage of the model :. Then, we will interpolate the just added set of samples. In order to carry out these spatial operations, we first need to import the corresponding library.

fmModel.InitialWaterLevel.SetValues(initialWaterLevels)
Code Block
languagepy
titleAdd values to model
sample points to initital water level
from Libraries.SpatialOperations import * 
samplePoints = AddSamplePoints(fmModel, fmModel.InitialWaterLevel, measuredWaterLevels, subsetName = "subset water level measurements", sampleOperationName = "measurements 1-Jan-2012")
InterpolateSamplePoints(samplePoints[0], samplePoints[1], interpName ="Interpolated water level measurements")

Finally, we set the initial water level to 0.15 m for all the points that haven't been assigned any value after the interpolation. We do this for the entire domain (Envelope of the domain).

Code Block
languagepy
titleSet default value to locations without any value
 AddSpatialOperationByPolygon("SetValue", fmModel, fmModel.InitialWaterLevel, "Envelope", values = [0.15], pointwiseType = "OverwriteWhereMissing")

The initial conditions have now been fully specified. Let's now proceed with the model parameters.

To limit the calculation time, we change the maximum and initial delta t (time) to 1 hour using the SetModelProperty function.

Code Block
languagepy
titleSet dtMax and dtInitial
# set model max and initial timestep size
timeStep = timedelta(hours=1)

SetModelProperty(fmModel, KnownProperties.DtMax, str(timeStep.total_seconds()))
SetModelProperty(fmModel, KnownProperties.DtInit, str(timeStep.total_seconds()))

scrollbar