Skip to content
Snippets Groups Projects
Program.cs 5.44 KiB
Newer Older
  • Learn to ignore specific revisions
  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Mes_Wind_console
    {
        class Program
        {
            static void Main(string[] args)
            {
                const int rowCountPrognostic = 3;
                const int colCountPrognostic = 3;
                WindStressPRM.Matrix<WindStressPRM.PrognosticCell> prognosticMatrix = new WindStressPRM.Matrix<WindStressPRM.PrognosticCell>();
                prognosticMatrix.Cells = new WindStressPRM.PrognosticCell[rowCountPrognostic, colCountPrognostic];
                prognosticMatrix.Size = new WindStressPRM.CellSize(500, 500);
                prognosticMatrix.Origin = new WindStressPRM.Coordinate(3555223.71, 5828444.07);
                // fill cells of prognostic matrix
                for (int i = 0; i < rowCountPrognostic; i++)
                {
                    for (int j = 0; j < colCountPrognostic; j++)
                    {
                        // Also you can use Double.NaN;
                        double uValue = 100*( i + j * 10);
                        double vValue = -(i + j * 10);
                        prognosticMatrix.Cells[i, j] = new WindStressPRM.PrognosticCell(uValue, vValue);
                    }
                }
                //Now we create climate raster class
                const int rowCountClim = 3;
                const int columnCountClim = 3;
                WindStressPRM.Matrix<WindStressPRM.ClimateCell> climateMatrix = new WindStressPRM.Matrix<WindStressPRM.ClimateCell>();
                climateMatrix.Cells = new WindStressPRM.ClimateCell[rowCountClim, columnCountClim];
                climateMatrix.Size = new WindStressPRM.CellSize(500, 500);
                climateMatrix.Origin = new WindStressPRM.Coordinate(3555223.71, 5828444.07);
                // fill cells of climate matrix
                for (int i = 0; i < rowCountClim; i++)
                {
                    for (int j = 0; j < columnCountClim; j++)
                    {
                        //add or substruct in range 0 - 27 to change what lines will be broken 
                        double clim5 = 5;
                        double clim10 = 10;
                        double clim15 = 15;
                        double clim25 = 20;
                        climateMatrix.Cells[i, j] = new WindStressPRM.ClimateCell(clim5, clim10, clim15, clim25);
                    }
                }
                // create powerlines layer
                List<WindStressPRM.Powerline> powerlines = new List<WindStressPRM.Powerline>();
                WindStressPRM.Coordinate first = climateMatrix.Origin;
                const int numbStations = 5;
                const double step = 100;
                for (int i = 0; i < numbStations - 1; i++)
                {
                    WindStressPRM.Powerline dummyline = new WindStressPRM.Powerline();
                    dummyline.Identifier = 100 + i;
                    dummyline.Year = 2000;
                    dummyline.Height = 10;
                    dummyline.Voltage = 330;
                    dummyline.PointFromID = i;
                    dummyline.PointToID = i + 1;
                    dummyline.Coordinates = new List<WindStressPRM.Coordinate>();
                    dummyline.Coordinates.Add(first);
                    WindStressPRM.Coordinate second = new WindStressPRM.Coordinate(first.X + step, first.Y - step);
                    dummyline.Coordinates.Add(second);
                    first = second;
                    powerlines.Add(dummyline);
                }
                //create PRM_station list to pass to PRM_wind from loaded point layer
                List<WindStressPRM.PowerStation> powerpoints = new List<WindStressPRM.PowerStation>();
                for (int i = 0; i < numbStations; i++)
                {
                    WindStressPRM.PowerStation dummystation = new WindStressPRM.PowerStation();
                    dummystation.Identifier = i;
                    dummystation.Name = "dummy name";
                    dummystation.Power = 330;
                    dummystation.IsSource = i == 0;
    
                    //casting stationtype
                    dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Pole;
                    if (i == numbStations - 1)
                    {
                        dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Endstat;
                    }
                    dummystation.Coordinate = new WindStressPRM.Coordinate(climateMatrix.Origin.X + step * i, climateMatrix.Origin.X - step * i);
                    powerpoints.Add(dummystation);
                }
                //Create a PRM_wind class and add all the properties from above
                WindStressPRM.StressPowerChecker prmwind = new WindStressPRM.StressPowerChecker();
                WindStressPRM.Input input = new WindStressPRM.Input();
                input.PowerLines = powerlines;
                input.PowerStations = powerpoints;
                input.PrognosticCells = prognosticMatrix;
                input.ClimateCells = climateMatrix;
                WindStressPRM.Output output = prmwind.CheckPower(input);
                foreach (WindStressPRM.Powerline line in output.DisabledLines) {
                    Console.WriteLine("disabled line identifier is " + line.Identifier.ToString());
                }
                foreach (WindStressPRM.PowerStation station in output.DisabledStations) {
                    Console.WriteLine("disabled station identifier is " + station.Identifier.ToString());
                }
                foreach (WindStressPRM.Coordinate coordinate in output.SpectificCoordinates) {
                    Console.WriteLine("in coordinate " + coordinate.X.ToString() + "; " + coordinate.Y.ToString() + " 35kV and less could be broken");
                }
                Console.WriteLine("end");
            }
        }
    }