Versions Compared

Key

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

scrollbar

When adding boundary conditions to the a model, you must first declare the type of the boundary you want to add. This is done as follows for a waterlevel timeseries:their type. In the example of this tutorial, we will add a time series of water levels to each boundary. Each of the added boundary conditions is also kept inside a separate variable for later use.

Code Block
languagepy
titleCreare Create timeseries boundaries
flowLeftBoundaryCondition = AddFlowBoundaryCondition(fmModel, leftBoundary.Name, FlowBoundaryQuantityType.WaterLevel, BoundaryConditionDataType.TimeSeries)
flowTopBoundaryCondition = AddFlowBoundaryCondition(fmModel, topBoundary.Name, FlowBoundaryQuantityType.WaterLevel, BoundaryConditionDataType.TimeSeries)
flowBottomBoundaryCondition = AddFlowBoundaryCondition(fmModel, bottomBoundary.Name, FlowBoundaryQuantityType.WaterLevel, BoundaryConditionDataType.TimeSeries)
flowRightBoundaryCondition = AddFlowBoundaryCondition(fmModel, rightBoundary.Name, FlowBoundaryQuantityType.WaterLevel, BoundaryConditionDataType.TimeSeries)

This can be seen on is reflected in the map on , with a different icon for the boundary conditions:

We continue by assigning the start time and the end time of each series. These same times will be used later on for the model as well as start and end simulation time. Additionally, a list containing the set of couples of boundary objects,and their respective specifications is also created.

Code Block
titleCreate timeseries
from datetime import datetime, time, timedelta

startTime = 
Code Block
languagepy
titleAdd timeseries to boundary supportpoint
boundaryTimeSeries = [[datetime(2014,1,1, 12,0,0), 2.0],
endTime              [= datetime(2014,1,212, 12,0,0), 2.2

boundaryConditionSets = [[leftBoundary,flowLeftBoundaryCondition],
              [datetime(2014,1,3, 12,0,0), -1.8],
          [topBoundary,flowTopBoundaryCondition],
        [datetime(2014,1,4, 12,0,0), 2.0],
              [datetime(2014,1,5, 12,0,0), -2.0bottomBoundary, flowBottomBoundaryCondition],
              [datetime(2014,1,6, 12,0,0), 2.0],
              [datetime(2014,1,7, 12,0,0), -2.0],
              [datetime(2014,1,8, 12,0,0), 2.0]]

AddTimeSeriesToSupportPoint(fmModel, flowLeftBoundaryCondition, 0, boundaryTimeSeries)
AddTimeSeriesToSupportPoint(fmModel, flowLeftBoundaryCondition, 2, boundaryTimeSeries)
AddTimeSeriesToSupportPoint(fmModel, flowLeftBoundaryCondition, 5, boundaryTimeSeries)

AddTimeSeriesToSupportPoint(fmModel, flowTopBoundaryCondition, 0, boundaryTimeSeries)

 

 

Image Removed

 

          [rightBoundary, flowRightBoundaryCondition]]

Now, we will use a WPS server to retrieve the time series for the support points of the boundaries. We start by importing the WPS library. This may take some time and ends up with some error messages which can be ignored.

Code Block
languagepy
titleImport WPS library
import Libraries.Wps as wps

We go through the previously created list boundaryConditionSets and, for each pair, we call GetTidalPredictForLineString to retrieve every boundary from the WPS server. This will provide us a time series for each support point on each boundary, with the provided start time, stop time and frequency. This may take some time depending on the number of support points, the length of the time series and the speed of your internet connection.

Once retrieved, we add these time series to the model by using AddTimeSeriesToSupportPoint for each support point.

Code Block
languagepy
titleAdd WPS boundary conditions
for boundaryConditionSet in boundaryConditionSets:
    # get timeseries for each support point using wps service
    timeSeries = wps.GetTidalPredictForLineString(boundaryConditionSet[0].Geometry, EPSGCode, startTime, endTime, wps.Frequency.Hourly)

    # add resultTimeSeries to support points
    for supportPointIndex in range(len(timeSeries)):
        resultTimeSeries = timeSeries[supportPointIndex]
        AddTimeSeriesToSupportPoint(fmModel, boundaryConditionSet[1], supportPointIndex, resultTimeSeries)

The result can be viewed double clicking any boundary on the map and looking at the boundary conditions editor:

Image Added

In the figure above, a water level time series has been assigned to all the support points of the left boundary condition. 

scrollbar