Exemplo n.º 1
0
        /// <summary> 从文件读取生产信息 </summary>
        public SCHEDULE RefreshRestartSchdule(RestartInfoModel restart)
        {
            //  创建关键字
            SCHEDULE schedule = new SCHEDULE("SCHEDULE");

            if (restart.SchPath != null && File.Exists(restart.SchPath))
            {
                INCLUDE include = FileFactoryService.Instance.ThreadLoadFromFile(restart.SchPath);
                schedule.Add(include);
            }
            else
            {
                return(restart.Schedule);
            }

            return(schedule);
        }
        /// <summary> 通关生产数据创建生产数据 </summary>
        public SCHEDULE InitRestartSchdule(SCHEDULE sch, RestartInfoModelSimON model, string name, DateTime time)
        {
            //  创建关键字
            SCHEDULE schedule = new SCHEDULE("SCHEDULE");
            INCLUDE  include  = new INCLUDE("INCLUDE");

            include.FileName = name + "_SCH.DAT";
            include.FilePath = Path.GetDirectoryName(model.ResultFilePath) + "//" + include.FileName;
            model.SchPath    = include.FilePath;
            schedule.Add(include);

            //int findIndex = ds.FindIndex(l => (l.Date.Date - time.Date).TotalDays == 0);

            //if (findIndex == -1)
            //{
            //    throw new Exception("SimalorManager.InitRestartSchdule:没有对应日期的时间步:" + time.ToShortDateString());
            //}

            sch.DeleteAll <TIME>(l => l.Date.Date < time.Date);


            List <VFPINJ> Vins = sch.FindAll <VFPINJ>();

            List <VFPPROD> Vpns = sch.FindAll <VFPPROD>();

            //ds.RemoveRange(0, findIndex);

            if (Vins.Count > 0)
            {
                include.AddRange(Vins);
            }

            if (Vpns.Count > 0)
            {
                include.AddRange(Vpns);
            }

            //  处理井数据
            List <TIME> ds = sch.FindAll <TIME>();

            include.AddRange(ds);

            return(schedule);
        }
Exemplo n.º 3
0
        /// <summary> 将Eclipse生产数据转换成SimON生产数据 </summary>
        public SCHEDULE ConvertToSimON(SCHEDULE sch, WELL location, DateTime startTime, BaseFile history)
        {
            // Todo :保存SCH

            SCHEDULE schedule = new SCHEDULE("SCHEDULE");

            List <string> wellNames = new List <string>();

            List <WELSPECS> ws = sch.FindAll <WELSPECS>();

            // Todo :查找所有井名
            ws.ForEach(l => wellNames.AddRange(l.Items.Select(k => k.jm0)));

            List <NAME> histNames = new List <NAME>();

            // Todo :初始化名称 生产_historyproduction.dat
            wellNames.ForEach(l => histNames.Add(new NAME("NAME")
            {
                WellName = l
            }));

            histNames.ForEach(l => history.Key.Add(l));


            // Todo :初始化完井WELL数据
            List <NAME> names = new List <NAME>();

            wellNames.ForEach(l => names.Add(new NAME("NAME")
            {
                WellName = l
            }));

            names.ForEach(l => location.Add(l));

            List <DATES> ds = sch.FindAll <DATES>();

            string format = "井名:{0} ({1},{2})";

            // Todo :添加起始信息到时间步
            DATES start = new DATES("DATES", startTime);

            sch.DeleteAll <DATES>();

            start.AddRange <BaseKey>(sch.Keys);

            ds.Insert(0, start);

            List <PERF> comAllTemp = new List <PERF>();

            foreach (DATES d in ds)
            {
                // Todo :对缓存中完井井名去重复取最后一条
                var distincts = comAllTemp.GroupBy(l => l.WellName + l.I0 + l.J1 + l.K12).ToList();
                comAllTemp.Clear();
                foreach (var item in distincts)
                {
                    comAllTemp.Add(item.Last());
                }

                //  创建SimON日期
                TIME time = new TIME("TIME");
                time.Date = d.DateTime;
                schedule.Add(time);

                var wconprod = d.FindAll <WCONPROD>();
                var wconhist = d.FindAll <WCONHIST>();
                var wconinje = d.FindAll <WCONINJE>();
                var wconinjh = d.FindAll <WCONINJH>();

                //  完井数据(考虑到排序)
                List <BaseKey> compdats = d.FindAll <BaseKey>(l => l is COMPDAT || l is WELOPEN);

                List <WPIMULT> wpimult = d.FindAll <WPIMULT>();

                List <WELOPEN> welopen = d.FindAll <WELOPEN>();

                #region - 添加没有生产信息的完井 -
                //  添加完井数据
                foreach (BaseKey c in compdats)
                {
                    if (c is COMPDAT)
                    {
                        COMPDAT com = c as COMPDAT;

                        foreach (COMPDAT.Item citem in com.Items)
                        {
                            // Todo :过滤有生产数据的,用后面方法处理
                            if (wconprod.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0)))
                            {
                                continue;
                            }
                            if (wconhist.Exists(l => l.Items.Exists(k => k.wellName0 == citem.jm0)))
                            {
                                continue;
                            }
                            if (wconinje.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0)))
                            {
                                continue;
                            }
                            if (wconinjh.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0)))
                            {
                                continue;
                            }

                            WELLCTRL well = time.Find <WELLCTRL>(l => l.WellName0 == citem.jm0);

                            if (well == null)
                            {
                                // Todo :创建一个空的生产信息
                                well           = new WELLCTRL("WELLCTRL");
                                well.ProType   = SimONProductType.NA;
                                well.WellName0 = citem.jm0;
                                time.Add(well);
                            }

                            NAME name = names.Find(l => l.WellName == well.WellName0);

                            #region - SCh数据 -

                            PERF perf = new PERF("PERF");
                            perf.WellName = well.WellName0;
                            perf.I0       = citem.i1;
                            perf.J1       = citem.j2;
                            perf.K12      = citem.swg3;
                            perf.K23      = citem.xwg4;
                            perf.Kgbs4    = citem.kgbz5;
                            perf.Jzs6     = citem.ljyz7;
                            perf.WjfxX7   = citem.skfx12 == "X" ? "DX" : "0";
                            perf.WjfxY8   = citem.skfx12 == "Y" ? "DY" : "0";
                            perf.WjfxZ9   = citem.skfx12 == "Z" ? "DZ" : "0";
                            perf.Bp10     = citem.bpxs10;

                            // Todo :查找井指数乘子
                            foreach (WPIMULT wp in wpimult)
                            {
                                var v = wp.Items.Find(l => l.jm0 == well.WellName0);

                                if (v != null)
                                {
                                    perf.Jzscz5 = v.jzscz1;
                                    break;
                                }
                            }

                            // Todo :增加前先删除存在的重复数据
                            well.DeleteAll <PERF>(l => l.I0 == perf.I0 && l.J1 == perf.J1 && l.K12 == perf.K12);
                            well.Add(perf);

                            #endregion

                            #region - WELL数据 -

                            NAME.Item nameItem = new NAME.Item();
                            nameItem.i0    = citem.i1;
                            nameItem.j1    = citem.j2;
                            nameItem.k12   = citem.swg3;
                            nameItem.k23   = citem.xwg4;
                            nameItem.kgbz4 = citem.kgbz5;
                            //nameItem.wi5 = "NA";// v.Value.skin.Value.Value.ToString();
                            //nameItem.dx6 = v.Value.wellIndex.Value.GetValue(v.Value.wellIndex.GetUnitValue(_ecl)).ToString();
                            //nameItem.dy7 = v.Value.wellDirection.Value.Value == "X" ? "0" : v.Value.wellDirection.Value.Value == "Y" ? "1" : "2";
                            nameItem.bpxs9 = citem.bpxs10;
                            nameItem.jj10  = (citem.jtnj8.ToDouble() / 2).ToString();
                            name.Items.Add(nameItem);
                            #endregion

                            comAllTemp.Add(perf);
                        }
                    }
                    else if (c is WELOPEN)
                    {
                        WELOPEN wp = c as WELOPEN;

                        foreach (var v in wp.Items)
                        {
                            // Todo :过滤有生产数据的,用后面方法处理
                            if (wconprod.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0)))
                            {
                                continue;
                            }
                            if (wconhist.Exists(l => l.Items.Exists(k => k.wellName0 == v.jm0)))
                            {
                                continue;
                            }
                            if (wconinje.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0)))
                            {
                                continue;
                            }
                            if (wconinjh.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0)))
                            {
                                continue;
                            }
                            // WELOPEN
                            //'G13' 'SHUT' 0 0 0 2 * /
                            // /

                            // Todo :查找之前所有完井
                            var coms = comAllTemp.FindAll(l => l.WellName == v.jm0);

                            Predicate <PERF> match = l => true;

                            // Todo :0 或 *表示默认值全都取
                            if (v.i2 != KeyConfiger.EclipseDefalt && v.i2 != "0")
                            {
                                match += l => l.I0 == v.i2;
                            }

                            if (v.j3 != KeyConfiger.EclipseDefalt && v.j3 != "0")
                            {
                                match += l => l.J1 == v.j3;
                            }

                            if (v.k4 != KeyConfiger.EclipseDefalt && v.k4 != "0")
                            {
                                match += l => l.K12 == v.k4;
                            }

                            var findComs = coms.FindAll(match);

                            WELLCTRL well = time.Find <WELLCTRL>(l => l.WellName0 == v.jm0);
                            if (well == null)
                            {
                                // Todo :创建一个空的生产信息
                                well           = new WELLCTRL("WELLCTRL");
                                well.ProType   = SimONProductType.NA;
                                well.WellName0 = v.jm0;
                                time.Add(well);
                            }

                            // Todo :增加WELOPEN控制的完井
                            foreach (var fitem in findComs)
                            {
                                PERF perf = fitem.Copy();
                                perf.Kgbs4 = v.jz1;
                                // Todo :增加前先删除存在的重复数据
                                well.DeleteAll <PERF>(l => l.I0 == fitem.I0 && l.J1 == fitem.J1 && l.K12 == fitem.K12);
                                well.Add(perf);
                            }
                        }
                    }

                    //this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp);
                }

                #endregion


                foreach (var item in wconprod)
                {
                    foreach (WCONPROD.ItemHY it in item.Items)
                    {
                        //  生产数据
                        WELLCTRL well = new WELLCTRL("WELLCTRL");

                        well.WellName0 = it.jm0;

                        well = this.ConvertToSimON(it, d, histNames);

                        if (well != null)
                        {
                            this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp);

                            time.Add(well);
                        }
                    }
                }


                foreach (var item in wconhist)
                {
                    foreach (WCONHIST.Item it in item.Items)
                    {
                        //  生产数据
                        WELLCTRL well = new WELLCTRL("WELLCTRL");

                        well.WellName0 = it.wellName0;

                        well = this.ConvertToSimON(it, d, histNames);

                        this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp);

                        time.Add(well);
                    }
                }


                foreach (var item in wconinje)
                {
                    foreach (WCONINJE.ItemHY it in item.Items)
                    {
                        //  生产数据
                        WELLCTRL well = new WELLCTRL("WELLCTRL");

                        well.WellName0 = it.jm0;

                        well = this.ConvertToSimON(it, d, histNames);

                        this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp);

                        time.Add(well);
                    }
                }

                foreach (var item in wconinjh)
                {
                    foreach (WCONINJH.Item it in item.Items)
                    {
                        //  生产数据
                        WELLCTRL well = new WELLCTRL("WELLCTRL");

                        well.WellName0 = it.jm0;

                        well = this.ConvertToSimON(it, d, histNames);

                        this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp);

                        time.Add(well);
                    }
                }

                //// Todo :将之前的完井信息都加入到缓存中
                //foreach (var item in compdats)
                //{
                //    comAllTemp.AddRange(item.Items);
                //}
            }

            return(schedule);
        }
        /// <summary> 通关生产数据创建生产数据(目前只应用在FieldGoal案例重启)  </summary>
        public SCHEDULE InitRestartSchduleRestartCase(SCHEDULE sch, RestartInfoModelSimON model, string name, DateTime time, DateTime endtime, Dictionary <string, double> wellProducts, int datype)
        {
            //  创建关键字
            SCHEDULE schedule = new SCHEDULE("SCHEDULE");
            INCLUDE  include  = new INCLUDE("INCLUDE");

            include.FileName = name + "_SCH.DAT";
            include.FilePath = Path.GetDirectoryName(model.ResultFilePath) + "//" + include.FileName;
            model.SchPath    = include.FilePath;
            schedule.Add(include);

            include.Add(new USESTARTTIME("USESTARTTIME"));
            include.Add(new RECURRENT("WELLSCHED"));
            TIME start = new TIME("TIME", time);

            foreach (var item in wellProducts)
            {
                WELLCTRL well = new WELLCTRL("WELLCTRL");
                well.WellName0 = item.Key;
                well.ProType   = datype == 0 ? SimONProductType.GRAT : datype == 1? SimONProductType.ORAT: SimONProductType.LRAT;
                well.Jcyblxz2  = item.Value.ToString();
                start.Add(well);
            }

            TIME startAdd = new TIME("TIME", time.AddDays(1));

            TIME end = new TIME("TIME", endtime);

            end.Add(new RegisterKeys.SimON.STEPRST("STEPRST"));

            List <VFPINJ> Vins = sch.FindAll <VFPINJ>();

            List <VFPPROD> Vpns = sch.FindAll <VFPPROD>();

            if (Vins.Count > 0)
            {
                include.AddRange(Vins);
            }

            if (Vpns.Count > 0)
            {
                include.AddRange(Vpns);
            }

            include.Add(start);

            if (startAdd.Date < end.Date)
            {
                include.Add(startAdd);
            }

            if (end.Date.Date == start.Date.Date)
            {
                include.Add(startAdd);
            }
            else
            {
                include.Add(end);
            }



            // HTodo  :保存生产文件
            include.Save();

            return(schedule);


            // HTodo  :示例如下
            //USESTARTTIME
            //WELLSCHED
            //TIME    20140209D
            //       WELL   'PROD1'   4   9000   1500
            //       WELL   'INIJ1'   5   6000   NA

            //TIME    20140210D

            //TIME    20140309D
            //RESTART
        }
Exemplo n.º 5
0
        /// <summary> 清理父节点 </summary>
        public void InitParentKey()
        {
            RUNSPEC runspec = this.Key.CreateSingle <RUNSPEC>("RUNSPEC");

            GRID grid = this.Key.CreateSingle <GRID>("GRID");

            if (grid != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_grid.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                INCLUDE include1 = new INCLUDE("INCLUDE");
                include1.FileName = this.FileName.GetFileNameWithoutExtension() + "_faults.inc";
                include1.FilePath = this.FilePath.GetDirectoryName() + "\\" + include1.FileName;
                grid.Add(include1);

                INCLUDE include2 = new INCLUDE("INCLUDE");
                include2.FileName = this.FileName.GetFileNameWithoutExtension() + "_aquifer.inc";
                include2.FilePath = this.FilePath.GetDirectoryName() + "\\" + include1.FileName;
                grid.Add(include2);
            }

            EDIT edit = this.Key.Find <EDIT>();

            if (edit != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_edit.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                edit.Add(include);
            }



            PROPS props = this.Key.CreateSingle <PROPS>("PROPS");

            if (props != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_pvt.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                props.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_rp.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                props.Add(include);
            }


            SOLUTION solution = this.Key.CreateSingle <SOLUTION>("SOLUTION");

            if (solution != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_init.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                solution.Add(include);
            }



            REGIONS region = this.Key.CreateSingle <REGIONS>("REGIONS");

            if (region != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_regs.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                region.Add(include);
            }

            SUMMARY summary = this.Key.CreateSingle <SUMMARY>("SUMMARY");

            if (summary != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sum.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                summary.Add(include);

                //if (include.Keys.Count == 0)
                //{
                //    ALL all = new ALL("ALL");
                //    include.Add(all);
                //}
            }

            SCHEDULE schedule = this.Key.CreateSingle <SCHEDULE>("SCHEDULE");

            if (schedule != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sch.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                schedule.Add(include);
            }


            END end = this.Key.CreateSingle <END>("END");
        }
Exemplo n.º 6
0
        /// <summary> 清理父节点 </summary>
        public void InitParentKey(bool isCoal = false)
        {
            this.Key.Clear();

            this.Key.CreateSingle <SIMSET>("SIMSET");

            GRID grid = this.Key.CreateSingle <GRID>("GRID");

            if (grid != null)
            {
                //  增加屏显
                ECHO_OFF echo_off = new ECHO_OFF("ECHO_OFF");
                grid.Add(echo_off);

                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_REG.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GPRO.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GGO.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GOTH.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                //  关闭屏显
                ECHO_ON echo_on = new ECHO_ON("ECHO_ON");
                grid.Add(echo_on);
            }

            this.Key.CreateSingle <MODIFY>("MODIFY");

            WELL well = this.Key.CreateSingle <WELL>("WELL");

            USE_TF use_tf = new USE_TF("USE_TF");

            if (well != null)
            {
                well.Add(use_tf);

                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_WELL.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                well.Add(include);
            }



            PROPS props = this.Key.CreateSingle <PROPS>("PROPS");

            if (props != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_SAT.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                props.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_PVT.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                props.Add(include);
            }
            if (isCoal)
            {
                ADSORB adsorb = this.Key.CreateSingle <ADSORB>("ADSORB");

                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_ADS.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                adsorb.Add(include);
            }


            SOLUTION solution = this.Key.CreateSingle <SOLUTION>("SOLUTION");

            if (solution != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_INI.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                solution.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_AQU.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                solution.Add(include);
            }

            TUNESET tuneset = this.Key.CreateSingle <TUNESET>("TUNESET");


            SOLVECTRL solvectrl = new SOLVECTRL("SOLVECTRL");

            tuneset.Add(solvectrl);

            //if (solvectrl != null)
            //{
            //    INCLUDE include = new INCLUDE("INCLUDE");
            //    include.FileName = this.FileName.GetFileNameWithoutExtension() + "_TUN.DAT";
            //    include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
            //    solvectrl.Add(include);
            //}

            //SUMMARY summary = this.Key.CreateSingle<SUMMARY>("SUMMARY");
            //if (summary != null)
            //{
            //    INCLUDE include = new INCLUDE("INCLUDE");
            //    include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sum.inc";
            //    include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
            //    summary.Add(include);

            //    //if (include.Keys.Count == 0)
            //    //{
            //    //    ALL all = new ALL("ALL");
            //    //    include.Add(all);
            //    //}
            //}

            SCHEDULE schedule = this.Key.CreateSingle <SCHEDULE>("SCHEDULE");

            if (schedule != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_SCH.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                schedule.Add(include);
            }


            //END end = this.Key.CreateSingle<END>("END");

            //  输出关键字
            OUTSCHED rptsched = new OUTSCHED("RPTSCHED");

            this.Key.Add(rptsched);
        }