//----------------------------------------------------------------------- // // Copyright (c) 2010 Deltares. All rights reserved. // // B.S.T. The // tom.the@deltares.nl // 8-9-2010 // //----------------------------------------------------------------------- namespace Deltares.Piping.Data { using System.Collections.Generic; public class PipingDAMInput { private const double cQ1 = 16000.0; private const double cQ2 = 15000.0; private const double cQ3 = 10000.0; private const double cQ4 = 4000.0; private const double cQ5 = 2000.0; public List fRegionInfos = new List(); private PipingCommonData fCommonData = new PipingCommonData(); private List fLocationGeometries = new List(); private List fLocationSoils = new List(); private List fLocationSegmentSoilRelations = new List(); private List fPipingDAMWaterLevels = new List(); public List RegionInfos { get { return fRegionInfos; } } public PipingCommonData CommonData { get { return fCommonData; } } public List LocationGeometries { get { return fLocationGeometries; } } public List LocationSoils { get { return fLocationSoils; } } public List LocationSegmentSoilRelations { get { return fLocationSegmentSoilRelations; } } public List PipingDAMWaterLevels { get { return fPipingDAMWaterLevels; } } /// /// Find geometry that belongs to the given location name /// /// /// public PipingDAMLocationGeometryStruct GetLocationGeometry(string aLocationName) { PipingDAMLocationGeometryStruct selectedLocationGeometry = new PipingDAMLocationGeometryStruct("", "", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); foreach (PipingDAMLocationGeometryStruct locationGeometry in fLocationGeometries) { if (locationGeometry.Name == aLocationName) { selectedLocationGeometry = locationGeometry; break; } } return selectedLocationGeometry; } /// /// Find soil for given soilname /// /// /// public PipingDAMLocationSoilStruct GetSoil(string aName) { PipingDAMLocationSoilStruct selectedSoil = new PipingDAMLocationSoilStruct("", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); foreach (PipingDAMLocationSoilStruct soil in fLocationSoils) { if (soil.Name == aName) { selectedSoil = soil; break; } } return selectedSoil; } /// /// Find soil list belonging to given location name /// /// /// public List GetLocationSoils(string aLocationName) { List locationSoils = new List(); PipingDAMLocationGeometryStruct selectedLocationGeometry = GetLocationGeometry(aLocationName); if (selectedLocationGeometry.Name != "") { foreach (PipingDAMSegmentSoilRelationStruct segmentSoilRelation in LocationSegmentSoilRelations) { if (segmentSoilRelation.SegmentName == selectedLocationGeometry.SegmentName) { PipingDAMLocationSoilStruct soil = GetSoil(segmentSoilRelation.SoilName); if (soil.Name != "") { soil.ChanceOccurence = segmentSoilRelation.ChanceOccurence; locationSoils.Add(soil); } } } } return locationSoils; } /// /// Find waterlevel info belonging to given location name /// /// /// public PipingDAMWaterLevelInfoStruct GetLocationWaterLevelInfo(string aLocationName) { PipingDAMWaterLevelInfoStruct selectedWaterLevel = new PipingDAMWaterLevelInfoStruct("", 0.0, 0.0, 0.0, 0.0, 0.0); foreach (PipingDAMWaterLevelInfoStruct waterLevel in fPipingDAMWaterLevels) { if (waterLevel.LocationName == aLocationName) { selectedWaterLevel = waterLevel; break; } } return selectedWaterLevel; } /// /// Determine waterlevel at certain location given the waterflow in Lobith /// /// /// public double DetermineWaterLevel(string aLocationName, double aFlowLobith) { double waterLevel = 0.0; PipingDAMWaterLevelInfoStruct waterLevelInfo = GetLocationWaterLevelInfo(aLocationName); if (waterLevelInfo.LocationName == aLocationName) { waterLevel = WaterLevelInterpolation(waterLevelInfo, aFlowLobith); } return waterLevel; } public double WaterLevelInterpolation(PipingDAMWaterLevelInfoStruct aWaterLevelInfo, double aFlow) { List waterLevelPoints = new List(); waterLevelPoints.Add(new PipingDAMQHPoint(cQ1, aWaterLevelInfo.H1)); waterLevelPoints.Add(new PipingDAMQHPoint(cQ2, aWaterLevelInfo.H2)); waterLevelPoints.Add(new PipingDAMQHPoint(cQ3, aWaterLevelInfo.H3)); waterLevelPoints.Add(new PipingDAMQHPoint(cQ4, aWaterLevelInfo.H4)); waterLevelPoints.Add(new PipingDAMQHPoint(cQ5, aWaterLevelInfo.H5)); if (aFlow >= waterLevelPoints[0].Q) { return waterLevelPoints[0].H; } if (aFlow <= waterLevelPoints[waterLevelPoints.Count - 1].Q) { return waterLevelPoints[waterLevelPoints.Count - 1].H; } PipingDAMQHPoint firstPoint = waterLevelPoints[0]; PipingDAMQHPoint secondPoint = waterLevelPoints[0]; for (int indexPoint = 1; indexPoint < waterLevelPoints.Count; indexPoint++) { firstPoint = waterLevelPoints[indexPoint - 1]; secondPoint = waterLevelPoints[indexPoint]; if (aFlow >= secondPoint.Q) { break; } } double factorQ = (firstPoint.Q - aFlow) / (firstPoint.Q - secondPoint.Q); double waterLevel = firstPoint.H - factorQ * (firstPoint.H - secondPoint.H); return waterLevel; } } }