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 start by creating a line geometry using the cell centers.
Code Block | |||||
---|---|---|---|---|---|
| |||||
# add initial conditions import csv measuredWaterLevelscoordinates = [cell.Center.X, cell.Center.Y] for cell in fmModel.Grid.Cells] with open(r"D:\Workshop\data\measuredWaterLevelFM.csv") as csvfile: lines = csv.reader(csvfile, delimiter=',') headers = lines.next() for line in lines: measuredWaterLevels.append(map(float, line)) |
Once loaded, we add the sample points to the initial 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.
Code Block | ||||||
---|---|---|---|---|---|---|
| initialConditions = wps.GetTidalPredictForTime(startTime, lineGeometry, EPSGCode)
fmModel.InitialWaterLevels.SetValues(initialConditions)
| |||||
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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
# 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())) |
Code Block | ||||
---|---|---|---|---|
| ||||
SetModelTimes(fmModel, startTime, endTime, time(6,0,0)) |
scrollbar |
---|