예제 #1
0
        public ConstitutiveRelations(string RockBlock, EOS eos, string Executable)
        {
            Rocks r = new Rocks();

            StreamReader sew = new StreamReader(new MemoryStream(ASCIIEncoding.ASCII.GetBytes(RockBlock)));

            while (!sew.ReadLine().StartsWith("ROCKS"))
            {
                ;
            }

            r.ReadFromStream(sew);

            RunSimu(r, eos, Executable);
        }
예제 #2
0
        /// <summary>
        /// Loads the mesh
        /// </summary>
        private void Load()
        {
            //now read input file
            using (ReaderUtilities sr = new ReaderUtilities(FileName))
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();

                    if (line.StartsWith("ROCKS"))
                    {
                        Rocks = new Rocks();
                        Rocks.ReadFromStream(sr);

                        foreach (Element e in Elements)
                        {
                            e.rock = Rocks[e.Material - 1];
                        }
                    }
                    else if (line.StartsWith("INCON"))
                    {
                        while ((line = sr.ReadLine().TrimEnd()) != String.Empty)
                        {
                            if (line.StartsWith("+++"))
                            {
                                break;
                            }

                            string elname = line.Substring(0, 5);

                            if (Elements.Contains(elname))
                            {
                                Elements[elname].Porosity = ReaderUtilities.SplitIntoDoubles(line, 15, 15)[0];

                                if (line.Length > 31)
                                {
                                    Elements[elname].PrimaryVariablesIndex = int.Parse(line.Substring(31, 1));
                                }

                                Elements[elname].PrimaryVaribles = ReaderUtilities.SplitIntoDoubles(sr.ReadLine(), 0, 20);
                            }
                        }
                    }
                    else if (line.StartsWith("PARAM"))
                    {
                        sr.ReadLine();
                        sr.ReadLine();
                        sr.ReadLine();
                        sr.ReadLine();
                        line = sr.ReadLine();
                        var arr = ReaderUtilities.SplitIntoDoubles(line, 0, 20);

                        foreach (var el in Elements)
                        {
                            if (el.PrimaryVaribles == null)
                            {
                                el.PrimaryVaribles = arr.ToArray();
                            }
                        }
                    }
                    else if (line.StartsWith("TSXCD"))
                    {
                        var arr  = sr.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        var ints = arr.Select(var => int.Parse(var));

                        foreach (var i in ints.Skip(1))
                        {
                            if (i <= Elements.Count)
                            {
                                detailedTimeSeries.Add(Elements[i - 1]);
                            }
                        }
                    }
                    else if (line.StartsWith("GENER"))
                    {
                        Wells = new Gener();
                        Wells.ReadFromStream(sr);
                    }
                }
                FileContent = sr.FileContent.ToString();
            }
            NotifyPropertyChanged("FileContent");
            NotifyPropertyChanged("DetailedTimeSeries");
        }
예제 #3
0
        private void RunSimu(Rocks rock, EOS eos, string Executable)
        {
            Model DummySim = null;

            switch (eos)
            {
            case EOS.t2eco2m:
                DummySim = new Model(@"C:\Jacob\Udvikling\NewT2voc\DotNetT2VOC\RelPermTemp\eco2m.txt");
                break;

            case EOS.t2eco2n:
                break;

            case EOS.t2voc:
                break;

            default:
                break;
            }

            DummySim.Rocks = rock;

            DummySim.FileContent = "DummyTitle \n" + rock.ToString() + DummySim.FileContent;

            DummySim.simu.Executable = Executable;

            WaterRelativePermeability               = new Dictionary <Rock, IEnumerable <Point> >();
            GasCO2RelativePermeability              = new Dictionary <Rock, IEnumerable <Point> >();
            LiquidCO2RelativePermeability           = new Dictionary <Rock, IEnumerable <Point> >();
            LiquidCO2ThreePhaseRelativePermeability = new Dictionary <Rock, IEnumerable <Point3D> >();
            GasCO2ThreePhaseRelativePermeability    = new Dictionary <Rock, IEnumerable <Point3D> >();

            for (int j = 0; j < rock.Count; j++)
            {
                foreach (var el in DummySim.Elements)
                {
                    el.Material = j + 1;
                }
                DummySim.SaveMesh();
                DummySim.simu.Run(false);
                DummySim.SaveOutput("Output.txt");

                if (DummySim.simu.si.ExitInfo != CauseOfStop.ConvergenceFailure)
                {
                    Succeded = true;
                    List <Point>   _waterrel = new List <Point>();
                    List <Point>   _gasrel   = new List <Point>();
                    List <Point>   _liqrel   = new List <Point>();
                    List <Point3D> _intrel   = new List <Point3D>();
                    List <Point3D> _gas3rel  = new List <Point3D>();

                    var res = DummySim.Results.Vectors[0];
                    for (int i = 0; i < DummySim.Elements.Count; i++)
                    {
                        _waterrel.Add(new Point(res["SAQ"][i], res["K(AQ)"][i]));

                        if (res["SLIQ"][i] == 0)
                        {
                            _gasrel.Add(new Point(res["SGAS"][i], res["K(GAS)"][i]));
                        }

                        if (res["SGAS"][i] == 0)
                        {
                            _liqrel.Add(new Point(res["SLIQ"][i], res["K(LIQ.)"][i]));
                        }


                        _intrel.Add(new Point3D(res["SAQ"][i], res["SLIQ"][i], res["K(LIQ.)"][i]));
                        _gas3rel.Add(new Point3D(res["SAQ"][i], res["SGAS"][i], res["K(GAS)"][i]));
                    }
                    WaterRelativePermeability.Add(rock[j], _waterrel.Distinct(new PointComparerByX()).OrderBy(var => var.X));
                    GasCO2RelativePermeability.Add(rock[j], _gasrel.Distinct(new PointComparerByX()).OrderBy(var => var.X));
                    LiquidCO2RelativePermeability.Add(rock[j], _liqrel.Distinct(new PointComparerByX()).OrderBy(var => var.X));

                    LiquidCO2ThreePhaseRelativePermeability.Add(rock[j], _intrel);
                    GasCO2ThreePhaseRelativePermeability.Add(rock[j], _gas3rel);
                }
                else
                {
                    this.Succeded = false;
                }
            }
        }