-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathStructureScripts.cs
55 lines (51 loc) · 2.04 KB
/
StructureScripts.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using DHI.Mike1D.Mike1DDataAccess;
using DHI.Mike1D.Plugins;
using DHI.Mike1D.StructureModule;
namespace DHI.Mike1D.Examples.Scripts
{
/// <summary>
/// Misc scripts for updating structure parameters
/// </summary>
public class StructureScripts
{
/// <summary>
/// The Underflow gate has a couple of parameters to stabilize the transition between
/// the different flow regimes. This script methods sets these parameters for all UnderFlowGate
/// structures.
/// </summary>
[Script]
public void UpdateUnderflowGateTransitionCoefficients(Mike1DData mike1DData)
{
foreach (IStructure structure in mike1DData.Network.StructureCollection.Structures)
{
IUnderFlowGate underFlowGate = structure as IUnderFlowGate;
if (underFlowGate != null)
{
// Coefficient used to avoid instabilities when switching from subcritical to critical
underFlowGate.SurchargedUnderflowCoefficient = 0.1;
// Coefficient used to avoid instabillities when switching from submerged gate to not submerged gate.
underFlowGate.UnderflowTransitionCoefficient = 0.1;
}
}
}
/// <summary>
/// The EnergyLoss structure solves a set of energy-loss equations using an iterative approach.
/// This can be somewhat unstable. A number of iterative methods have been implemented,
/// and choosing another method can make an unstable energy-loss structure stable.
/// </summary>
[Script]
public void UpdateEnergyLossSolverMethod(Mike1DData mike1DData)
{
foreach (IStructure structure in mike1DData.Network.StructureCollection.Structures)
{
EnergyLoss energyLoss = structure as EnergyLoss;
if (energyLoss != null)
{
// The Mike11Mod method keeps upstream and downstream energy level constant, regardless
// of actual flow through the structure.
energyLoss.SolverMethod = EnergyLoss.EnergyLossSolverMethod.Mike11Mod;
}
}
}
}
}