Please find a snippet below illustrating the usage. The script has not been carefully tested. Accordingly, I cannot give any warranty that the script is working properly.
[font=courier][color=blue]
This script shows how to use time-dependent material properties
### Time-dependent material properties will be stored within a dac-file
### In this example an artificial groundwater recharge is assigned
### which varies in time and in space
### Requirement: math module
### Assumption layered based model
import sys
import os
import math
sys.path.append('C:\\Program Files\\DHI\\2017\\FEFLOW 7.1\\bin64')
import ifm
def preTimeStep(d):
global nElements, nDimensions
t = doc.getAbsoluteSimulationTime()
print >> sys.stdout, t
e0 = int(math.floor(t))
x0 = doc.getX(e0)
y0 = doc.getY(e0)
for nElement in range(0, nElements):
x = doc.getX(nElement)
y = doc.getY(nElement)
doc.setMatFlowSinkSource(nElement, t*math.hypot(x-x0,y-y0))
try:
# Get current working directory
dir = os.getcwd()
# Definition of files
FEM_FILE = dir + "\\..\\femdata\\AssignTimeDependentMaterial.fem"
FEM_FILE__id_OUT = dir + "\\..\\results\\AssignTimeDependentMaterial_id.dac"
# Load document
doc = ifm.loadDocument(FEM_FILE)
# Get number of elements
nElements = doc.getNumberOfElementsPerLayer()
# Set parameter ID
ParamID = 107 #ID for In/outflow on top or bottom for 3D
if nDimensions == 2:
print >> sys.stdout, "The groundwater recharge is only represented by the source/sink parameter in 2D models."
print >> sys.stdout, "Use paremeter ID 113 for In/outflow on top/bottom and impose the elements."
if nDimensions == 3:
# Allow parameter recording
ParaMeterRec = 1 # 0 = no recording, 1 = recording
# Enable parameter recording for groundwater recharge
doc.enableParamRecording(ParamID, ParaMeterRec)
# Start Simulator
doc.startSimulator(FEM_FILE__id_OUT)
# Strop Simulator
doc.stopSimulator()
except Exception as err:
sys.exit(-1);
[/color][/font]