Versions Compared

Key

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

scrollbar

We start by creating a list of coordinates using reading the waterlevels at the cell centers (the initial waterlevel values are defined per cell)from a CSV (Comma separated values) file.

coordinates = [[cell.Center.X, cell.Center.Y] for cell in fmModel.Grid.Cells]
Code Block
languagepy
titleSet intial confitions

 

Then we get the waterlevel for these coordinates at the start time and set them as the initial waterlevel of our model.

Code Block
languagepy
titleSet intial confitions
# add initial conditions 
import csv

initialWaterLevels = []

initialCsvFilePathwith = open("D:\\Workshop\\initial.csv"



with open(initialCsvFilePath) as csvfile: 

    lines = csv.reader(csvfile, delimiter=',')

   

    for line in lines:

        initialWaterLevels.append(float(line[0]))



fmModel.InitialWaterLevels.SetValues(initialWaterLevels)

 

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