Exemplo n.º 1
0
        public void save()
        {
            List <WellLogSample> LogDens = new List <WellLogSample>(densLog.Samples);
            Borehole             b1      = densLog.Borehole;

            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                ILogTemplate            glob = pvs.FindTemplateByMnemonics("Velocity");
                PropertyVersion         pv   = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                //log.Name = "rhoB";
                WellLogSample[] tsamples = new WellLogSample[count];
                for (int i2 = 0; i2 < count; i2++)
                {
                    double md  = LogDens[i2].MD;
                    float  val = (float)vel[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
            PetrelLogger.InfoBox("The Velocity Log has been created in the same Well");
        }
Exemplo n.º 2
0
 private void CreateWell(Well well, BoreholeCollection boreholeColl)
 {
     using (ITransaction tr = DataManager.NewTransaction())
     {
         tr.Lock(boreholeColl);
         Borehole borehole = boreholeColl.CreateBorehole(well.Name);
         borehole.Comments = "Imported from FIELDPRO";
         borehole.UWI      = well.Uwi;
         var coordinates = well.CartesianCoordinates();
         borehole.WellHead = new Point2(coordinates["X"], coordinates["Y"]);
         ReferenceLevel kb = new ReferenceLevel("KB", well.Z, "Kelly bushing");
         borehole.WorkingReferenceLevel = kb;
         var trajectoryRecords = this.GetTrajectoryRecords(well);
         try { borehole.Trajectory.Records = trajectoryRecords; }
         catch (ArgumentOutOfRangeException ex)
         {
             PetrelLogger.InfoOutputWindow("Failed to set trajectory: " + ex.ToString());
         }
         SetProperty("Field", well.Field, borehole, true);
         SetProperty("Area", well.Area, borehole, true);
         SetProperty("Country", well.Country, borehole, true);
         SetProperty("FIELDPRO ID", well.ID.ToString(), borehole, false);
         tr.Commit();
     }
 }
        void _ReadBoreholes(
            DGObjects objs,
            string tableNameSQL,
            string conditionSQL,
            string orderSQL)
        {
            ReadRawData(objs, tableNameSQL, orderSQL, conditionSQL);
            DataTable table = objs.rawDataSet.Tables[0];
            foreach (DataRow row in table.Rows)
            {
                if (IsDbNull(row, "ID"))
                    continue;

                Borehole bh = new Borehole(row);
                bh.ID = ReadInt(row, "ID").Value;
                bh.Name = ReadString(row, "Name");
                bh.FullName = ReadString(row, "FullName");
                bh.Description = ReadString(row, "Description");
                bh.shape = ReadShape(row);

                bh.Type = ReadString(row, "BoreholeType");
                bh.Top = ReadDouble(row, "TopElevation").Value;
                bh.Base = bh.Top - ReadDouble(row, "BoreholeLength").Value;
                bh.Mileage = ReadDouble(row, "Mileage");

                objs[bh.key] = bh;
            }
        }
        public static List<IPolyline3> CreatingPolyLineListWhenWellHasPerforations(Borehole bh)
        {
            List<IPolyline3> plineList = new List<IPolyline3>();

            foreach (Perforation prf in bh.Completions.Perforations)
            {
                double x1 = bh.Transform(Domain.MD, prf.StartMD, Domain.X);
                double y1 = bh.Transform(Domain.MD, prf.StartMD, Domain.Y);
                double z1 = bh.Transform(Domain.MD, prf.StartMD, Domain.ELEVATION_DEPTH);

                List<Point3> ptsList = new List<Point3>();
                Point3 pt3_1 = new Point3(x1, y1, z1);
                ptsList.Add(pt3_1);

                double x2 = bh.Transform(Domain.MD, prf.EndMD, Domain.X);
                double y2 = bh.Transform(Domain.MD, prf.EndMD, Domain.Y);
                double z2 = bh.Transform(Domain.MD, prf.EndMD, Domain.ELEVATION_DEPTH);

                Point3 pt3_2 = new Point3(x2, y2, z2);

                double xmiddle = (x1 + x2)/2;
                double ymiddle = (y1 + y2) / 2;
                double zmiddle = (z1 + z2) / 2;

                Point3 pt3_3 = new Point3(xmiddle, ymiddle, zmiddle);
                ptsList.Add(pt3_3);
                ptsList.Add(pt3_2);

                IPolyline3 pline = new Polyline3(ptsList);

                plineList.Add(pline);
            }

            return plineList;
        }
            public static WellLogVersion CreateWellLogVersionFromWellLog(WellLog wellLog)
            {
                WellLogVersion wellLogVersion = WellLogVersion.NullObject;
                //
                Borehole borehole = wellLog.Borehole;
                //
                Template wellLogTemplate = wellLog.WellLogVersion.Template;
                //
                WellRoot wellRoot = WellRoot.Get(PetrelProject.PrimaryProject);
                //
                var logVersionCollection = wellRoot.LogVersionCollection;

                //
                if (!borehole.Logs.CanCreateWellLog(wellLog.WellLogVersion))
                {
                    using (var transaction = DataManager.NewTransaction())
                    {
                        transaction.Lock(logVersionCollection);
                        //
                        wellLogVersion = logVersionCollection.CreateWellLogVersion("Copied " + wellLog.WellLogVersion.Name,
                                                                                   wellLogTemplate);
                        //
                        transaction.Commit();
                    }
                }
                //
                return(wellLogVersion);
            }
Exemplo n.º 6
0
        //List<Borehole> b2 = new List<Borehole>();
        //public Borehole b1;

        public void save(WellLog LogType, int count, double startMD, double interval, Double[] array, string name)
        {
            //Borehole b1;
            //int count = LogType.SampleCount;

            List <WellLogSample> TypeLog = new List <WellLogSample>(LogType.Samples);
            Borehole             b1      = LogType.Borehole;

            //List<Borehole> b2 = new List<Borehole>();
            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                ILogTemplate            glob = pvs.FindTemplateByMnemonics(name);
                PropertyVersion         pv   = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                //log.Name = "rhoB";
                WellLogSample[] tsamples = new WellLogSample[count];
                for (int i2 = 0; i2 < count; i2++)
                {
                    double md  = startMD + i2 * interval;
                    float  val = (float)array[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
        }
Exemplo n.º 7
0
        public void FromSonic()
        {
            int count = dtLog.SampleCount;

            List <WellLogSample> LogDt = new List <WellLogSample>(dtLog.Samples);

            double[] Imp = new double[count];

            for (int i = 0; i < count; i++)
            {
                Imp[i] = 1000.0d * GCoef * Math.Pow(1 / dtLog[i].Value, GExp) / dtLog[i].Value;
            }
            Borehole b1 = dtLog.Borehole;

            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                ILogTemplate            glob = pvs.FindTemplateByMnemonics("Acoustic Impedance");
                PropertyVersion         pv   = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                //log.Name = "rhoB";
                WellLogSample[] tsamples = new WellLogSample[count];
                for (int i2 = 0; i2 < count; i2++)
                {
                    double md  = LogDt[i2].MD;
                    float  val = (float)Imp[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
            PetrelLogger.InfoBox("The Impedance Log has been created in the same Well");
        }
Exemplo n.º 8
0
        private static string GetProperty(Borehole well, string propertyName)
        {
            BoreholePropertyCollection bhPropertyColl = well.BoreholeCollection.BoreholePropertyCollection;
            DictionaryBoreholeProperty dicProperty    = FindDictionaryProperty(bhPropertyColl, propertyName);

            return(well.PropertyAccess.GetPropertyValue <string>(dicProperty).ToString());
        }
Exemplo n.º 9
0
        public void FromDensity()
        {
            //int count = Math.Min(velLog.SampleCount, densLog.SampleCount);

            List <WellLogSample> LogVel  = new List <WellLogSample>(velLog.Samples);
            List <WellLogSample> LogDens = new List <WellLogSample>(densLog.Samples);

            TwoLogCheck c2    = new TwoLogCheck(velLog, densLog);
            int         count = c2.count;

            if (count == 0)
            {
                PetrelLogger.ErrorBox("INPUT LOGS DO NOT HAVE SAME DEPTH SPACING");
                return;
            }
            double startMD = c2.startMD, endMD = c2.endMD;
            int    startVel = c2.startLog1, startDens = c2.startLog2;

            double[] Imp = new double[count];

            for (int i = 0; i < count; i++)
            {
                if (LogDens[i + startDens].Value.ToString() == "NaN")
                {
                    continue;
                }

                if (LogVel[i + startVel].Value.ToString() == "NaN")
                {
                    continue;
                }

                vel    = LogVel[i + startVel].Value;
                rhob   = LogDens[i + startDens].Value;
                Imp[i] = vel * rhob;
            }
            Borehole b1 = densLog.Borehole;

            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                ILogTemplate            glob = pvs.FindTemplateByMnemonics("Acoustic Impedance");
                PropertyVersion         pv   = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                //log.Name = "rhoB";
                WellLogSample[] tsamples = new WellLogSample[count];

                for (int i2 = 0; i2 < count; i2++)
                {
                    double md  = startMD + i2 * c2.interval2;
                    float  val = (float)Imp[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
            PetrelLogger.InfoBox("The Impedance Log has been created in the same Well");
        }
Exemplo n.º 10
0
 private static void ShowBoreholeInWindow3D(Window3D window3D, Borehole borehole)
 {
     // show the borehole in the window3d if possible
     if (borehole != Borehole.NullObject && window3D.CanShowObject(borehole))
     {
         window3D.ShowObject(borehole);
     }
 }
Exemplo n.º 11
0
 private static void HideBoreholeInWindow3D(Window3D window3D, Borehole borehole)
 {
     // if there is alreay a well made visible by this command hide it
     if (borehole != Borehole.NullObject && window3D.IsVisible(borehole))
     {
         window3D.HideObject(borehole);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        ///     带参数的构造方法
        /// </summary>
        /// <param name="borehole"></param>
        public BoreholeInfoEntering(Borehole borehole)
        {
            InitializeComponent();

            // 设置窗体默认属性
            FormDefaultPropertiesSetter.SetEnteringFormDefaultProperties(this, Const_GM.UPDATE_BOREHOLE_INFO);
            using (new SessionScope())
            {
                borehole = Borehole.Find(borehole.BoreholeId);
                // 孔号
                txtBoreholeNumber.Text = borehole.BoreholeNumber;
                // 地面标高
                txtGroundElevation.Text = borehole.GroundElevation.ToString(CultureInfo.InvariantCulture);
                // X坐标
                txtCoordinateX.Text = borehole.CoordinateX.ToString(CultureInfo.InvariantCulture);
                // Y坐标
                txtCoordinateY.Text = borehole.CoordinateY.ToString(CultureInfo.InvariantCulture);
                // Z坐标
                txtCoordinateZ.Text = borehole.CoordinateZ.ToString(CultureInfo.InvariantCulture);

                // 获取岩性信息

                DataBindUtil.LoadLithology(LITHOLOGY);

                // 明细


                gvCoalSeamsTexture.RowCount = borehole.BoreholeLithologys.Count + 1;
                for (var i = 0; i < borehole.BoreholeLithologys.Count; i++)
                {
                    // 岩性名称
                    var iLithologyId = borehole.BoreholeLithologys[i].Lithology.LithologyId;

                    var lithology = Lithology.Find(iLithologyId);

                    gvCoalSeamsTexture[0, i].Value = lithology.LithologyName;
                    // 底板标高
                    gvCoalSeamsTexture[1, i].Value = borehole.BoreholeLithologys[i].FloorElevation;
                    // 厚度
                    gvCoalSeamsTexture[2, i].Value = borehole.BoreholeLithologys[i].Thickness;
                    // 煤层名称
                    gvCoalSeamsTexture[3, i].Value = borehole.BoreholeLithologys[i].CoalSeamsName;

                    // 坐标X
                    gvCoalSeamsTexture[4, i].Value =
                        borehole.BoreholeLithologys[i].CoordinateX.ToString(CultureInfo.InvariantCulture);

                    // 坐标Y
                    gvCoalSeamsTexture[5, i].Value =
                        borehole.BoreholeLithologys[i].CoordinateY.ToString(CultureInfo.InvariantCulture);

                    // 坐标Z
                    gvCoalSeamsTexture[6, i].Value =
                        borehole.BoreholeLithologys[i].CoordinateX.ToString(CultureInfo.InvariantCulture);
                }
            }
        }
Exemplo n.º 13
0
 public WellKh(Borehole SelectedWell, Property SelectedPermeability, DictionaryProperty SelectedZoneIndex)
 {
     this.permeability = SelectedPermeability;
     this.well = SelectedWell;
     this.ZoneIndex = SelectedZoneIndex;
     this.root = ColorTableRoot.Get(PetrelProject.PrimaryProject);
     this.ListOfNamesOfIntersectedZones = new List<string>();
     this.KhWellTesting = -1;
 }
Exemplo n.º 14
0
        public void fromimpedance()
        {
            //int count;
            //count = ImpLog.SampleCount;
            List <WellLogSample> LogImp = new List <WellLogSample>(ImpLog.Samples);
            List <WellLogSample> LogVel = new List <WellLogSample>(VelLog.Samples);

            TwoLogCheck C2    = new TwoLogCheck(ImpLog, VelLog);
            int         count = C2.count;

            if (count == 0)
            {
                PetrelLogger.ErrorBox("INPUT LOGS DO NOT HAVE SAME DEPTH SPACING");
                return;
            }
            int startImp = C2.startLog1, startVel = C2.startLog2;

            double[] rhob = new double[count];

            for (int i = 0; i < count; i++)
            {
                if (LogImp[i + startImp].Value.ToString() == "NaN")
                {
                    continue;
                }

                if (LogVel[i + startVel].Value.ToString() == "NaN")
                {
                    continue;
                }
                rhob[i] = (double)LogImp[i + startImp].Value / LogVel[i + startVel].Value;
            }
            Borehole b1 = ImpLog.Borehole;

            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                ILogTemplate            glob = pvs.FindTemplateByMnemonics("Density");
                PropertyVersion         pv   = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                //log.Name = "rhoB";
                WellLogSample[] tsamples = new WellLogSample[count];
                for (int i2 = 0; i2 < count; i2++)
                {
                    double md  = C2.startMD + C2.interval1 * i2;
                    float  val = (float)rhob[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
            PetrelLogger.InfoBox("The Density Log has been created in the same Well");
        }
Exemplo n.º 15
0
 public WellKh(Borehole SelectedWell, Property SelectedPermeability, double SelectedTop, double SelectedBottom )
 {
     this.permeability = SelectedPermeability;
     this.well = SelectedWell;
     this.top = SelectedTop;
     this.bottom = SelectedBottom;
     this.ZoneIndex = null;
     this.root = null;
     this.ListOfNamesOfIntersectedZones = null;
     this.KhWellTesting = -1;
 }
Exemplo n.º 16
0
 public IActionResult Put(long id, [FromBody] Borehole value)
 {
     value.Id = id;
     if (BoreholeProvider.Set(value))
     {
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
Exemplo n.º 17
0
        private void modify_Click(object sender, RoutedEventArgs e)
        {
            BoreholeServer server = new BoreholeServer(new BoreholeRepositoryForServer(new GeologyDbContext()));
            Borehole       obj    = new Borehole()
            {
                ID   = int.Parse(a.Text),
                Name = b.Text,
                Top  = int.Parse(c.Text),
            };

            output.Text += server.ModifyBorehole(obj) + "\r\n";
        }
Exemplo n.º 18
0
 public BoreholeDTO(Borehole b) : this()
 {
     id      = b.id;
     Top     = b.Top;
     Base    = b.Base;
     Mileage = b.Mileage;
     Type    = b.Type;
     foreach (BoreholeGeology bg in b.Geologies)
     {
         geologies.Add(new BoreholeGeologyDTO(bg));
     }
 }
Exemplo n.º 19
0
        public IActionResult Get(long id)
        {
            Borehole borehole = BoreholeProvider.Get(id);

            if (borehole == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(borehole));
            }
        }
Exemplo n.º 20
0
        public IActionResult Post([FromBody] Borehole value)
        {
            long res = BoreholeProvider.Add(value);

            if (res == 0)
            {
                return(BadRequest());
            }
            else
            {
                return(Ok(res));
            }
        }
Exemplo n.º 21
0
        public static Well Borehole2Well(Borehole b)
        {
            Well w = new Well();

            w.Name    = b.Name;
            w.Uwi     = b.UWI;
            w.X       = b.WellHead.X;
            w.Y       = b.WellHead.Y;
            w.Field   = GetProperty(b, "Field");
            w.Area    = GetProperty(b, "Area");
            w.Country = GetProperty(b, "Country");
            return(w);
        }
Exemplo n.º 22
0
        private static void UpdateWellPresenterFromWell(PresentationBox presenter, Borehole borehole)
        {
            var nameInfoFactory  = CoreSystem.GetService <INameInfoFactory>(borehole);
            var imageInfoFactory = CoreSystem.GetService <IImageInfoFactory>(borehole);
            //
            var nameInfo  = nameInfoFactory?.GetNameInfo(borehole);
            var imageInfo = imageInfoFactory?.GetImageInfo(borehole);

            //
            presenter.Text  = nameInfo?.Name;
            presenter.Image = imageInfo?.GetDisplayImage(new ImageInfoContext());
            presenter.Tag   = borehole;
        }
Exemplo n.º 23
0
        private void ImportObservedDataForWell(Borehole bh, List <WellAllocation> wellAllocations, ObservedDataSet observedDataSet)
        {
            ObservedDataSetForWell odsFw = ObservedDataSetForWell.NullObject;

            DeleteExistentDataSetForWell(bh, observedDataSet);

            string   opIdName = "Oil production rate";
            string   gpIdName = "Gas production rate";
            string   wpIdName = "Water production rate";
            string   wiIdName = "Water injection rate";
            string   ufIdName = "Uptime fraction";
            FlowType flow     = FlowType.Default;

            var timeSteps = new List <DateTime>();

            using (ITransaction tr = DataManager.NewTransaction())
            {
                Template opt = PetrelProject.WellKnownTemplates.ProductionGroup.ProductionRateOil;
                Template gpt = PetrelProject.WellKnownTemplates.ProductionGroup.ProductionRateGas;
                Template wpt = PetrelProject.WellKnownTemplates.ProductionGroup.ProductionRateWater;
                Template wit = PetrelProject.WellKnownTemplates.ProductionGroup.InjectionRateWater;
                Template utf = PetrelProject.WellKnownTemplates.ProductionGroup.UptimeFraction;
                tr.Lock(observedDataSet);
                odsFw = observedDataSet.CreateObservedDataSetForWell(bh, flow, timeSteps);

                // Create each data version (columns)
                CreateEmptyObservedData(odsFw, opt, opIdName);
                CreateEmptyObservedData(odsFw, gpt, gpIdName);
                CreateEmptyObservedData(odsFw, wpt, wpIdName);
                CreateEmptyObservedData(odsFw, wit, wiIdName);
                CreateEmptyObservedData(odsFw, utf, ufIdName);

                // Append data
                foreach (WellAllocation allocation in wellAllocations)
                {
                    odsFw.Append(
                        allocation.OperativeDate,
                        odsFw.ObservedDatas,
                        new List <double> {
                        ProductionRate(allocation.Oil, allocation.EffectiveTime),
                        ProductionRate(allocation.Gas, allocation.EffectiveTime),
                        ProductionRate(allocation.Water, allocation.EffectiveTime),
                        ProductionRate(allocation.WaterInjection, allocation.EffectiveTime),
                        allocation.EffectiveTime
                    });
                }
                tr.Commit();
            }
        }
        /// <summary>
        ///     带参数的构造方法
        /// </summary>
        /// <params name="borehole"></params>
        public BoreholeInfoEntering(Borehole borehole)
        {
            InitializeComponent();
            using (new SessionScope())
            {
                borehole = Borehole.Find(borehole.id);
                // 孔号
                txtBoreholeNumber.Text = borehole.name;
                // 地面标高
                txtGroundElevation.Text = borehole.ground_elevation.ToString(CultureInfo.InvariantCulture);
                // X坐标
                txtCoordinateX.Text = borehole.coordinate_x.ToString(CultureInfo.InvariantCulture);
                // Y坐标
                txtCoordinateY.Text = borehole.coordinate_y.ToString(CultureInfo.InvariantCulture);
                // Z坐标
                txtCoordinateZ.Text = borehole.coordinate_z.ToString(CultureInfo.InvariantCulture);

                // 获取岩性信息

                // 明细
                gvCoalSeamsTexture.RowCount = borehole.sub_boreholes.Count + 1;
                for (var i = 0; i < borehole.sub_boreholes.Count; i++)
                {

                    gvCoalSeamsTexture[0, i].Value = LITHOLOGY.Selected;
                    // 底板标高
                    gvCoalSeamsTexture[1, i].Value = borehole.sub_boreholes[i].floor_elevation;
                    // 厚度
                    gvCoalSeamsTexture[2, i].Value = borehole.sub_boreholes[i].thickness;
                    // 煤层名称
                    gvCoalSeamsTexture[3, i].Value = borehole.sub_boreholes[i].coal_seam;

                    // 坐标X
                    gvCoalSeamsTexture[4, i].Value =
                        borehole.sub_boreholes[i].coordinate_x.ToString(CultureInfo.InvariantCulture);

                    // 坐标Y
                    gvCoalSeamsTexture[5, i].Value =
                        borehole.sub_boreholes[i].coordinate_y.ToString(CultureInfo.InvariantCulture);

                    // 坐标Z
                    gvCoalSeamsTexture[6, i].Value =
                        borehole.sub_boreholes[i].coordinate_x.ToString(CultureInfo.InvariantCulture);
                }
            }
        }
Exemplo n.º 25
0
        /// <summary>
        ///     带参数的构造方法
        /// </summary>
        /// <params name="borehole"></params>
        public BoreholeInfoEntering(Borehole borehole)
        {
            InitializeComponent();
            using (new SessionScope())
            {
                borehole = Borehole.Find(borehole.id);
                // 孔号
                txtBoreholeNumber.Text = borehole.name;
                // 地面标高
                txtGroundElevation.Text = borehole.ground_elevation.ToString(CultureInfo.InvariantCulture);
                // X坐标
                txtCoordinateX.Text = borehole.coordinate_x.ToString(CultureInfo.InvariantCulture);
                // Y坐标
                txtCoordinateY.Text = borehole.coordinate_y.ToString(CultureInfo.InvariantCulture);
                // Z坐标
                txtCoordinateZ.Text = borehole.coordinate_z.ToString(CultureInfo.InvariantCulture);

                // 获取岩性信息


                // 明细
                gvCoalSeamsTexture.RowCount = borehole.sub_boreholes.Count + 1;
                for (var i = 0; i < borehole.sub_boreholes.Count; i++)
                {
                    gvCoalSeamsTexture[0, i].Value = LITHOLOGY.Selected;
                    // 底板标高
                    gvCoalSeamsTexture[1, i].Value = borehole.sub_boreholes[i].floor_elevation;
                    // 厚度
                    gvCoalSeamsTexture[2, i].Value = borehole.sub_boreholes[i].thickness;
                    // 煤层名称
                    gvCoalSeamsTexture[3, i].Value = borehole.sub_boreholes[i].coal_seam;

                    // 坐标X
                    gvCoalSeamsTexture[4, i].Value =
                        borehole.sub_boreholes[i].coordinate_x.ToString(CultureInfo.InvariantCulture);

                    // 坐标Y
                    gvCoalSeamsTexture[5, i].Value =
                        borehole.sub_boreholes[i].coordinate_y.ToString(CultureInfo.InvariantCulture);

                    // 坐标Z
                    gvCoalSeamsTexture[6, i].Value =
                        borehole.sub_boreholes[i].coordinate_x.ToString(CultureInfo.InvariantCulture);
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 向entity中写入数据,实例形式
        /// </summary>
        /// <param name="db">entity实例</param>
        /// <param name="data">数据对象</param>
        /// <returns></returns>
        public bool BoreholeInsert(GeologyDB_EF db, DGObjectDef objectDef, DataTable table)
        {
            for (int i = 3; i < table.Rows.Count; i++)
            {
                int           j    = 0;
                List <object> data = new List <object>();
                foreach (PropertyMeta property in objectDef.PropertyContainer)
                {
                    data.Add(table.Rows[i][j.ToString()]);
                }

                Borehole borehole = new Borehole {
                };
                db.Boreholes.Add(borehole);
            }
            db.SaveChanges();
            return(false);
        }
Exemplo n.º 27
0
        public void FromGamma()
        {
            int count;

            count = grLog.SampleCount;
            List <WellLogSample> LogGr = new List <WellLogSample>(grLog.Samples);

            double[] vsh = new double[count];
            double[] Gr  = new double[count];
            for (int i = 0; i < count; i++)
            {
                Gr[i]  = LogGr[i].Value;
                vsh[i] = (LogGr[i].Value - Gr0) / (Gr100 - Gr0);
            }
            double max = 0, min = 0;

            for (int k = 0; k < count; k++)
            {
                max = Math.Max(Gr[k], max);
                min = Math.Min(Gr[k], min);
            }

            Borehole b1 = grLog.Borehole;

            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                ILogTemplate            glob = pvs.FindTemplateByMnemonics("VShale");
                PropertyVersion         pv   = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);

                WellLogSample[] tsamples = new WellLogSample[count];
                for (int i2 = 0; i2 < count; i2++)
                {
                    double md  = LogGr[i2].MD;
                    float  val = (float)vsh[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
            PetrelLogger.InfoBox("The Shale Volume Fraction Log has been created in the same Well");
        }
Exemplo n.º 28
0
        private void SetProperty(string propertyName, string value, Borehole well, Boolean isPropertyGroup)
        {
            using (ITransaction tr = DataManager.NewTransaction())
            {
                BoreholePropertyCollection bhPropertyColl = well.BoreholeCollection.BoreholePropertyCollection;

                DictionaryBoreholeProperty dicProperty = DictionaryBoreholeProperty.NullObject;
                dicProperty = FindDictionaryProperty(bhPropertyColl, propertyName);
                if (dicProperty == null)
                {                   // Create attribute from BoreholePropertyCollection
                    tr.Lock(bhPropertyColl);
                    dicProperty = bhPropertyColl.CreateDictionaryProperty(typeof(string), propertyName);
                    dicProperty.IsGroupProperty = isPropertyGroup;
                }
                tr.Lock(well);
                well.PropertyAccess.SetPropertyValue(dicProperty, value);
                tr.Commit();
            }
        }
Exemplo n.º 29
0
        public override void Execute(Context context)
        {
            if (!CanExecute(context))
            {
                return;
            }
            //
            var window3D = (Window3D)context.GetActiveWindow();

            //
            // hide last selected borehole
            HideBoreholeInWindow3D(window3D, _selectedBorehole);
            //
            // then update the selected borehole
            _selectedBorehole = context.GetParameter <Borehole>(CommandParameterIds.Option);
            //
            // show newly selected borehole
            ShowBoreholeInWindow3D(window3D, _selectedBorehole);
        }
Exemplo n.º 30
0
        private void borehole_DragDrop(object sender, DragEventArgs e)
        {
            BR = (Borehole)e.Data.GetData(typeof(Borehole));
            if (BR != null)
            {
                BRname.Text = BR.Name;
            }
            else
            {
                BRname.Text = "";
                MessageBox.Show("Not a valid Borehole");
                return;
            }


            this.comboDensity.Items.Clear();
            this.comboSonic.Items.Clear();
            wlog.Clear();
            int tempctr1, tempctr2;
            int tempctr = 0;

            tempctr1 = 0;
            tempctr2 = 0;

            foreach (WellLog log in BR.Logs.WellLogs)
            {
                wlog.Add(log);
                this.comboDensity.Items.Add(log.Name);
                this.comboSonic.Items.Add(log.Name);
                tempctr++;
                if (log.Name.Contains("HO"))
                {
                    tempctr1 = tempctr;
                }
                else if (log.Name.Contains("DT"))
                {
                    tempctr2 = tempctr;
                }
            }
            this.comboDensity.SelectedIndex = tempctr1 - 1;
            this.comboSonic.SelectedIndex   = tempctr2 - 1;
        }
Exemplo n.º 31
0
        public override void Modify(Resource resource, Context context)
        {
            // find the current item
            Borehole borehole = context.GetParameter <Borehole>(CommandParameterIds.Option);

            //
            if (borehole == Borehole.NullObject)
            {
                return;
            }
            //
            // set attributes
            PetrelSystem.ResourceManager.SetAttributeValue(resource, WellKnownResourceAttributes.OptionText, borehole.Name);
            //
            var imageInfoFactory = CoreSystem.GetService <IImageInfoFactory>(borehole);
            var boreholeImage    = ImageData.FromImage(imageInfoFactory.GetImageInfo(borehole).GetDisplayImage(new ImageInfoContext()));

            PetrelSystem.ResourceManager.SetAttributeValue(resource, WellKnownResourceAttributes.OptionImage16, boreholeImage);
            PetrelSystem.ResourceManager.SetAttributeValue(resource, WellKnownResourceAttributes.OptionImage32, boreholeImage);
        }
Exemplo n.º 32
0
 private static void DeleteExistentDataSetForWell(Borehole bh, ObservedDataSet observedDataSet)
 {
     if (bh.ObservedDataSetCount > 0)
     {
         foreach (ObservedDataSetForWell tmpDS in bh.ObservedDataSets)
         {
             if (tmpDS.Name == observedDataSet.Name)
             {
                 using (ITransaction tr = DataManager.NewTransaction())
                 {
                     // Destructive delete of the previous observed data set for the well.
                     tr.Lock(tmpDS);
                     tmpDS.Delete();
                     tr.Commit();
                 }
                 break;
             }
         }
     }
 }
Exemplo n.º 33
0
        public void FromDensity2()
        {
            int count = densLog.SampleCount;

            List <WellLogSample> LogDens = new List <WellLogSample>(densLog.Samples);
            Velocity             V1      = new Velocity(densLog);

            V1.GCoef = GCoef;
            V1.GExp  = GExp;
            V1.FromDensity();
            double[] Imp = new double[count];

            for (int i = 0; i < count; i++)
            {
                rhob   = LogDens[i].Value;
                Imp[i] = V1.vel[i] * rhob;
            }

            Borehole b1 = densLog.Borehole;

            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                ILogTemplate            glob = pvs.FindTemplateByMnemonics("Acoustic Impedance");
                PropertyVersion         pv   = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                //log.Name = "rhoB";
                WellLogSample[] tsamples = new WellLogSample[count];

                for (int i2 = 0; i2 < count; i2++)
                {
                    double md  = LogDens[i2].MD;
                    float  val = (float)Imp[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
            PetrelLogger.InfoBox("The Impedance Log has been created in the same Well");
        }
Exemplo n.º 34
0
        /// <summary>
        ///     根据钻孔点名查找钻孔点信息
        /// </summary>
        /// <params name="strDisplayName"></params>
        /// <returns></returns>
        private IPoint GetProspectingBoreholePointSelected(String strDisplayName)
        {
            try
            {
                var brehole = Borehole.FindAllByProperty("name", strDisplayName).FirstOrDefault();

                IPoint pt = new PointClass();
                if (brehole != null)
                {
                    pt.X = brehole.coordinate_x;
                    pt.Y = brehole.coordinate_x;
                    pt.Z = brehole.coordinate_z;
                }

                return(pt);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 35
0
        // update and collect welllogs in arguments collections(res,vitr,son,den,por);
        private void AddData(Borehole borehole)
        {
            var tmp_res = GetCorrectType(borehole,TemplateType.ResistivityDeep);
            var tmp_vitr = GetCorrectType(borehole, TemplateType.VitriniteReflectance);

            // Psonic and Ssonic for Sonic
            var tmp_son = GetCorrectType(borehole, TemplateType.Psonic);
            var ssonic = GetCorrectType(borehole, TemplateType.Ssonic);

            // danger code for calculation !!!!!!!!!!
            if (borehole.Name == "Cooba-1" && ssonic.Count > 0)
                tmpargs.BritleWellLogDTS = ssonic[0];

            var tmp_den = GetCorrectType(borehole, TemplateType.DensityCompensatedBulk);
            var tmp_por = GetCorrectType(borehole, TemplateType.Porosity);

            res.Add(new MyData(tmp_res, TemplateType.ResistivityDeep));
            vitr.Add(new MyData(tmp_vitr, TemplateType.VitriniteReflectance));
            son.Add(new MyData(tmp_son, TemplateType.Psonic));
            den.Add(new MyData(tmp_den, TemplateType.Density));
            por.Add(new MyData(tmp_por, TemplateType.Porosity));
        }
        /// <summary>
        ///     未见煤钻孔
        /// </summary>
        /// <params name="breholeEntity">钻孔实体</params>
        private void DrawZuanKong(Borehole breholeEntity)
        {
            ////1.获得当前编辑图层
            //DrawSpecialCommon drawspecial = new DrawSpecialCommon();
            //string sLayerAliasName = LibCommon.LibLayerNames.DEFALUT_BOREHOLE;//“钻孔”图层
            //IFeatureLayer featureLayer = drawspecial.GetFeatureLayerByName(sLayerAliasName);
            //if (featureLayer == null)
            //{
            //    MessageBox.Show("未找到" + sLayerAliasName + "图层,无法绘制钻孔图元。");
            //    return;
            //}

            ////2.绘制图元
            //IPoint pt = new PointClass();
            //pt.X = breholeEntity.CoordinateX;
            //pt.Y = breholeEntity.CoordinateY;
            //pt.Z = breholeEntity.CoordinateZ;
            //if (pt.Z == double.NaN)
            //    pt.Z = 0;
            //GIS.SpecialGraphic.DrawZK2 drawZK2 = null;
            ////标注内容
            //string strH =breholeEntity.GroundElevation.ToString();//地面标高
            //string strName = breholeEntity.BoreholeNumber.ToString();//孔号(名称)

            //IFeature feature = featureLayer.FeatureClass.CreateFeature();
            //IGeometry geometry = pt;
            //DataEditCommon.ZMValue(feature, geometry);   //几何图形Z值处理
            ////drawspecial.ZMValue(feature, geometry);    //几何图形Z值处理
            //feature.Shape = pt;//要素形状
            ////要素ID字段赋值(对应属性表中BindingID)
            //int iFieldID = feature.Fields.FindField("ID");
            //feature.Value[iFieldID] = breholeEntity.bid.ToString();
            //feature.Store();//存储要素

            //string strValue = feature.get_Value(feature.Fields.FindField("OBJECTID")).ToString();
            //DataEditCommon.SpecialPointRenderer(featureLayer, "OBJECTID", strValue, drawZK2.m_Bitmap);

            /////3.显示钻孔图层
            //if (featureLayer.Visible == false)
            //    featureLayer.Visible = true;

            //IEnvelope envelop = feature.Shape.Envelope;
            //DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop;
            //DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
            //DataEditCommon.g_pMyMapCtrl.ActiveView.Refresh();

            IPoint pt = new PointClass();
            pt.X = breholeEntity.coordinate_x;
            pt.Y = breholeEntity.coordinate_y;
            pt.Z = breholeEntity.coordinate_z;
            if (double.IsNaN(pt.Z))
                pt.Z = 0;
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_BOREHOLE);
            if (pLayer == null)
            {
                MessageBox.Show(@"未找到钻孔图层,无法绘制钻孔图元。");
                return;
            }
            var pFeatureLayer = (IFeatureLayer)pLayer;
            IGeometry geometry = pt;
            var list = new List<ziduan>
            {
                new ziduan(GIS_Const.FIELD_BID, breholeEntity.bid),
                new ziduan(GIS_Const.FIELD_BOREHOLE_NUMBER, breholeEntity.name),
                new ziduan(GIS_Const.FIELD_ADD_TIME, DateTime.Now.ToString(CultureInfo.InvariantCulture)),
                new ziduan(GIS_Const.FIELD_GROUND_ELEVATION,
                    breholeEntity.ground_elevation.ToString(CultureInfo.InvariantCulture)),
                new ziduan(GIS_Const.FIELD_GROUND_FLOOR_ELEVATION, ""),
                new ziduan(GIS_Const.FIELD_THICKNESS, ""),
                new ziduan(GIS_Const.FIELD_TYPE, "1")
            };

            var pfeature = DataEditCommon.CreateNewFeature(pFeatureLayer, geometry, list);
            if (pfeature == null) return;
            MyMapHelp.Jump(pt);
            DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(
                (esriViewDrawPhase)34, null, null);
        }
Exemplo n.º 37
0
        //add data to list and show it
        void AddListData(Borehole borehole, int index)
        {
            //adding data to wellog collections
            AddData(borehole);

            String resist_ = res[index].Log.Count == 0? "0" : res[index].Log.Count.ToString();
            String vitrin_ = vitr[index].Log.Count == 0 ? "0" : vitr[index].Log.Count.ToString();
            String den_ = den[index].Log.Count == 0 ? "0" : den[index].Log.Count.ToString();
            String por_ = por[index].Log.Count == 0 ? "0" : por[index].Log.Count.ToString();
            String son_ = son[index].Log.Count == 0 ? "0" : son[index].Log.Count.ToString();

            IImageInfoFactory f = CoreSystem.GetService<IImageInfoFactory>(borehole);
            var item = new ListBoxItem();
            item.Text = string.Format("{0} (Resistivity: {1}; Vitrinite: {2},Density:{3},Porosity:{4},Sonic:{5})", borehole.Name, resist_, vitrin_, den_, por_, son_);

            if (res[index].Log.Count == 0 || vitr[index].Log.Count == 0 || res[index].Log.Count > 1 || vitr[index].Log.Count > 1)
                item.Image = PetrelImages.Warning;
            else if (den[index].Log.Count != 0 || por[index].Log.Count != 0 || son[index].Log.Count != 0)
                item.Image = f.GetImageInfo(borehole).TypeImage;
            else
                item.Image = PetrelImages.Warning;

            item.Value = borehole;
            list_Boreholes.Items.Add(item);
        }
Exemplo n.º 38
0
 //adding boreholes to borehole list,collecting data(welllogs) for computing and show results in list
 private void UpdateBoreholeList(Borehole borehole, int index)
 {
     if (!bholes.Contains(borehole))
     {
         AddListData(borehole, index);
         bholes.Add(borehole);
     }
 }
        public static Point3 GetIntersectingPoint(IPillarGridIntersectionService pgiservice, Grid GridInContext,Borehole bh, Index3 CellIndex, bool PerforatedZonesOnly)
        {
            Point3 IntersectionPoint;

            if (PerforatedZonesOnly) //if the user wants only perforated zones
            {
                if (bh.Completions.PerforationCount <= 0)
                {
                    IPolyline3 pline = bh.Trajectory.Polyline;

                    IEnumerable<SegmentCellIntersection> intersectionsegments;
                    intersectionsegments = pgiservice.GetPillarGridPolylineIntersections(GridInContext, pline);
                    foreach (SegmentCellIntersection sci in intersectionsegments)
                    {
                        if (CellIndex == sci.EnteringCell || CellIndex == sci.LeavingCell)
                        {
                            IntersectionPoint = sci.IntersectionPoint;
                            return IntersectionPoint;
                        }

                    }

                }
                else
                {
                    List<IPolyline3> plinelist = CreatingPolyLineListWhenWellHasPerforations(bh);

                    foreach (IPolyline3 poly in plinelist)
                    {
                        IEnumerable<SegmentCellIntersection> intersectionsegments;
                        intersectionsegments = pgiservice.GetPillarGridPolylineIntersections(GridInContext, poly);

                        foreach (SegmentCellIntersection sci in intersectionsegments)
                        {
                            if (CellIndex == sci.EnteringCell || CellIndex == sci.LeavingCell)
                            {
                                IntersectionPoint = sci.IntersectionPoint;
                                return IntersectionPoint;
                            }
                        }
                    }

                }
            }
            else
            {
                IPolyline3 pline = bh.Trajectory.Polyline;

                IEnumerable<SegmentCellIntersection> IntersectionSegments;
                IntersectionSegments = pgiservice.GetPillarGridPolylineIntersections(GridInContext, pline);
                foreach (SegmentCellIntersection sci in IntersectionSegments)
                {
                    if (CellIndex == sci.EnteringCell || CellIndex == sci.LeavingCell)
                    {
                        IntersectionPoint = sci.IntersectionPoint;
                        return IntersectionPoint;
                    }
                }

            }

            return null;
        }
        //Method that finds the distance from Face1 to Face2 of a cell passing through the center if both faces are directly opposite
        //public static double Plane2Plane_AvgDist(Plane3 Face1, Plane3 Face2, Point3 center)
        //{
        //     double dist;
        //     dist = Face1.AbsoluteDistance(center);
        //     dist = Face2.AbsoluteDistance(center) + dist;
        //     return dist;
        //}
        //Method to get all the CellSides from which the well entered the selected grid cells. The selected grid cells must intersect the well in order for the method to work.
        public static List<CellSide> GetListOfEnteringSidesOfIntersectedCells(IPillarGridIntersectionService pgiservice, Grid gridInContext, Borehole bh, List<Index3> ListOfSelectedIntersectingGridCells, bool PerforatedZonesOnly)
        {
            bool indx3_LeavingCell;
            List<CellSide> ListOfEnteringSides = new List<CellSide>();

            if (PerforatedZonesOnly) //If the user wants only perforated zones
            {
                if (bh.Completions.PerforationCount <= 0)
                {
                    IPolyline3 pline = bh.Trajectory.Polyline;

                    IEnumerable<SegmentCellIntersection> intersectionSegments;
                    intersectionSegments = pgiservice.GetPillarGridPolylineIntersections(gridInContext, pline);
                    foreach (SegmentCellIntersection sci in intersectionSegments)
                    {
                        Index3 indx3 = sci.EnteringCell;
                        if (indx3 != null)
                        {
                            indx3_LeavingCell = false;
                        }
                        else
                        {
                            indx3 = sci.LeavingCell;
                            indx3_LeavingCell = true;
                        }

                        foreach (Index3 cell in ListOfSelectedIntersectingGridCells)
                        {
                            if (cell == indx3)
                            {
                                if (!indx3_LeavingCell)
                                {
                                    ListOfEnteringSides.Add(sci.EnteringCellSide);
                                }
                                else
                                {
                                    ListOfEnteringSides.Add(sci.LeavingCellSide);
                                }
                            }
                        }
                    }

                }
                else
                {
                    List<IPolyline3> plineList = CreatingPolyLineListWhenWellHasPerforations(bh);

                    foreach (IPolyline3 poly in plineList)
                    {
                        IEnumerable<SegmentCellIntersection> intersectionSegments;
                        intersectionSegments = pgiservice.GetPillarGridPolylineIntersections(gridInContext, poly);

                        foreach (SegmentCellIntersection sci in intersectionSegments)
                        {
                            Index3 indx3 = sci.EnteringCell;
                            if (indx3 != null)
                            {
                                indx3_LeavingCell = false;
                            }
                            else
                            {
                                indx3 = sci.LeavingCell;
                                indx3_LeavingCell = true;
                            }

                            foreach (Index3 cell in ListOfSelectedIntersectingGridCells)
                            {
                                if (cell == indx3)
                                {
                                    if (!indx3_LeavingCell)
                                    {
                                        ListOfEnteringSides.Add(sci.EnteringCellSide);
                                    }
                                    else
                                    {
                                        ListOfEnteringSides.Add(sci.LeavingCellSide);
                                    }
                                }
                            }
                        }
                    }

                }
            }
            else
            {
                IPolyline3 pline = bh.Trajectory.Polyline;

                IEnumerable<SegmentCellIntersection> intersectionSegments;
                intersectionSegments = pgiservice.GetPillarGridPolylineIntersections(gridInContext, pline);
                foreach (SegmentCellIntersection sci in intersectionSegments)
                {
                    Index3 indx3 = sci.EnteringCell;
                    if (indx3 != null)
                    {
                        indx3_LeavingCell = false;
                    }
                    else
                    {
                        indx3 = sci.LeavingCell;
                        indx3_LeavingCell = true;
                    }

                    foreach (Index3 cell in ListOfSelectedIntersectingGridCells)
                    {
                        if (cell == indx3)
                        {
                            if (!indx3_LeavingCell)
                            {
                                ListOfEnteringSides.Add(sci.EnteringCellSide);
                            }
                            else
                            {
                                ListOfEnteringSides.Add(sci.LeavingCellSide);
                            }
                        }
                    }
                }

            }
            if (ListOfEnteringSides.Count != ListOfSelectedIntersectingGridCells.Count)
            { MessageBox.Show("One or more of the cells are not intersected by the borehole");
            return ListOfEnteringSides = null;
            }
            return ListOfEnteringSides;
        }
Exemplo n.º 41
0
        private void borehole_DragDrop(object sender, DragEventArgs e)
        {
            BR = (Borehole)e.Data.GetData(typeof(Borehole));
            if (BR != null)
            {
                BRname.Text = BR.Name;
            }
            else
            {
                BRname.Text = "";
                MessageBox.Show("Not a valid Borehole");
                return;
            }

            this.comboDensity.Items.Clear();
            this.comboSonic.Items.Clear();
            wlog.Clear();
            int tempctr1, tempctr2;
            int tempctr = 0;
            tempctr1 = 0;
            tempctr2 = 0;

            foreach (WellLog log in BR.Logs.WellLogs)
            {
                wlog.Add(log);
                this.comboDensity.Items.Add(log.Name);
                this.comboSonic.Items.Add(log.Name);
                tempctr++;
                if (log.Name.Contains("HO"))
                    tempctr1 = tempctr;
                else if (log.Name.Contains("DT"))
                    tempctr2 = tempctr;

            }
            this.comboDensity.SelectedIndex = tempctr1 - 1;
            this.comboSonic.SelectedIndex = tempctr2 - 1;
        }
        public static List<double> GetListOfPenetratedCellDistances(Grid gridInContext, Borehole bh, List<Index3> ListOfSelectedIntersectingGridCells, bool PerforatedZonesOnly, bool Vertical_only)
        {
            IPillarGridIntersectionService pgiservice = CoreSystem.GetService<IPillarGridIntersectionService>();
            Quadrilateral Face1;
            Quadrilateral Face2;
            CellCorner[] CellCorners = new CellCorner[4];
            Point3[] CellCornerPoints1 = new Point3[4];
            Point3[] CellCornerPoints2 = new Point3[4];
            CellSide Side = new CellSide() ;
            //Dictionary<Index3,List<double>> DictionaryOfSelectedCells = new Dictionary<Index3,List<double>>(ListOfSelectedIntersectingGridCells.Count);
               // List<double> Distance = new List<double>(3); //This array will contain the Height of the cell for the kh calculation and two extra elements that will be empty;
            List<double> Distance = new List<double>();

            if (!Vertical_only)
            {
                List<CellSide> ListOfEnteringSides = GetListOfEnteringSidesOfIntersectedCells(pgiservice, gridInContext, bh, ListOfSelectedIntersectingGridCells, PerforatedZonesOnly);
                for (int i = 0; i < ListOfEnteringSides.Count; i++)
                {
                    switch (ListOfEnteringSides[i])
                    {
                     case CellSide.Up:
                        CellCornerPoints1 = KandaIntersectionService.GetCornerSet(ListOfEnteringSides[i], gridInContext, ListOfSelectedIntersectingGridCells[i]);

                        Side = CellSide.Down;
                        CellCornerPoints2 = KandaIntersectionService.GetCornerSet(Side, gridInContext, ListOfSelectedIntersectingGridCells[i]);

                            break;

                     case CellSide.East:
                        CellCornerPoints1 = KandaIntersectionService.GetCornerSet(ListOfEnteringSides[i], gridInContext, ListOfSelectedIntersectingGridCells[i]);

                        Side = CellSide.West;
                        CellCornerPoints2 = KandaIntersectionService.GetCornerSet(Side, gridInContext, ListOfSelectedIntersectingGridCells[i]);

                            break;

                      case CellSide.West:
                           CellCornerPoints1 = KandaIntersectionService.GetCornerSet(ListOfEnteringSides[i], gridInContext, ListOfSelectedIntersectingGridCells[i]);

                        Side = CellSide.East;
                        CellCornerPoints2 = KandaIntersectionService.GetCornerSet(Side, gridInContext, ListOfSelectedIntersectingGridCells[i]);

                            break;

                      case CellSide.South:
                           CellCornerPoints1 = KandaIntersectionService.GetCornerSet(ListOfEnteringSides[i], gridInContext, ListOfSelectedIntersectingGridCells[i]);

                            Side = CellSide.North;
                            CellCornerPoints2 = KandaIntersectionService.GetCornerSet(Side, gridInContext, ListOfSelectedIntersectingGridCells[i]);

                            break;

                      case CellSide.North:
                           CellCornerPoints1 = KandaIntersectionService.GetCornerSet(ListOfEnteringSides[i], gridInContext, ListOfSelectedIntersectingGridCells[i]);

                        Side = CellSide.South;
                        CellCornerPoints2 = KandaIntersectionService.GetCornerSet(Side, gridInContext, ListOfSelectedIntersectingGridCells[i]);

                            break;

                        case CellSide.Down:
                            CellCornerPoints1 = KandaIntersectionService.GetCornerSet(ListOfEnteringSides[i], gridInContext, ListOfSelectedIntersectingGridCells[i]);

                        Side = CellSide.Up;
                        CellCornerPoints2 = KandaIntersectionService.GetCornerSet(Side, gridInContext, ListOfSelectedIntersectingGridCells[i]);

                            break;
                        default:

                            CellCornerPoints1 = null;
                            CellCornerPoints2= null;
                            break;
                    }

                    try
                    {
                        Face1 = new Quadrilateral(CellCornerPoints1[0], CellCornerPoints1[1], CellCornerPoints1[2], CellCornerPoints1[3]);
                    }
                    catch
                    {
                        Face1 = null;
                    }

                    try
                    {
                        Face2 = new Quadrilateral(CellCornerPoints2[0], CellCornerPoints2[1], CellCornerPoints2[2], CellCornerPoints2[3]);
                    }
                    catch
                    {
                        Face2 = null;
                    }

                    try
                    {
                        // Distance[0] = Face1.Centroid.Distance(Face2.Centroid);
                        //DictionaryOfSelectedCells.Add(ListOfSelectedIntersectingGridCells[i], Distance);
                        Distance.Add(Face1.Centroid.Distance(Face2.Centroid));
                    }
                    catch
                    {
                        Distance.Add(-1);
                        //DictionaryOfSelectedCells.Add(ListOfSelectedIntersectingGridCells[i], null);
                    }

                }
            }
            else //If only the vertical distance from top to base face of cell is required.
            {
                for (int i = 0; i < ListOfSelectedIntersectingGridCells.Count; i++)
                {
                    //CellCorners[0] = CellCorner.TopNorthWest; CellCorners[1] = CellCorner.TopNorthEast; CellCorners[2] = CellCorner.TopSouthWest;
                    //CellCorners[3] = CellCorner.TopSouthEast;
                    //CellCornerPoints = gridInContext.GetCellCorners(ListOfSelectedIntersectingGridCells[i], CellCorners);
                    Side = CellSide.Up;
                    CellCornerPoints1 = KandaIntersectionService.GetCornerSet(Side, gridInContext, ListOfSelectedIntersectingGridCells[i]);

                    Side = CellSide.Down;
                    CellCornerPoints2 = KandaIntersectionService.GetCornerSet(Side, gridInContext, ListOfSelectedIntersectingGridCells[i]);

                    try
                    {
                        Face1 = new Quadrilateral(CellCornerPoints1[0], CellCornerPoints1[1], CellCornerPoints1[2], CellCornerPoints1[3]);
                    }
                    catch
                    {
                        Face1 = null;
                    }

                    try
                    {
                        Face2 = new Quadrilateral(CellCornerPoints2[0], CellCornerPoints2[1], CellCornerPoints2[2], CellCornerPoints2[3]);
                    }
                    catch
                    {
                        Face2 = null;
                    }

                    try
                    {
                        // Distance[0] = Face1.Centroid.Distance(Face2.Centroid);
                        //DictionaryOfSelectedCells.Add(ListOfSelectedIntersectingGridCells[i], Distance);

                        if (!Double.IsNaN(Face1.Centroid.Distance(Face2.Centroid)))
                        {
                            Distance.Add(Face1.Centroid.Distance(Face2.Centroid));
                        }
                        else
                        {
                            Distance.Add(-1);
                        }
                    }
                    catch
                    {
                        Distance.Add(-1);
                        //DictionaryOfSelectedCells.Add(ListOfSelectedIntersectingGridCells[i], null);
                    }

                }
            }

            return Distance;
            //return DictionaryOfSelectedCells;
        }
        public static List<Index3> GetTheGridCellsIntersectedByWell(Grid gridInContext, Borehole bh, bool PerforatedZonesOnly)
        {
            IPillarGridIntersectionService pgiservice = CoreSystem.GetService<IPillarGridIntersectionService>();
            List<Index3> ListOfIntersectingGridCells = new List<Index3>();

            if (PerforatedZonesOnly)
            {
                if (bh.Completions.PerforationCount <= 0)
                {
                    IPolyline3 pline = bh.Trajectory.Polyline;
                    AddingWellGridIntersectionCellIndices(pgiservice, gridInContext, pline, ListOfIntersectingGridCells);
                }
                else
                {
                    List<IPolyline3> plineList = CreatingPolyLineListWhenWellHasPerforations(bh);
                    foreach (IPolyline3 pline in plineList)
                    {
                        AddingWellGridIntersectionCellIndices(pgiservice, gridInContext, pline, ListOfIntersectingGridCells);
                    }
                }
            }
            else
            {
                IPolyline3 pline = bh.Trajectory.Polyline;
                AddingWellGridIntersectionCellIndices(pgiservice, gridInContext, pline, ListOfIntersectingGridCells);
            }

            return ListOfIntersectingGridCells.Distinct().ToList();
        }
Exemplo n.º 44
0
 //add,check type welllogs
 private List<WellLog> GetCorrectType(Borehole borehole,TemplateType type)
 {
     return borehole.LogCollection.WellLogs.Where(p => p.WellLogVersion.Template.TemplateType == type).Select(p => p).ToList();
 }
Exemplo n.º 45
0
        public void workingFunction()
        {
            List<WellLogSample> den = new List<WellLogSample>(density.Samples);
            List<WellLogSample> dt = new List<WellLogSample>(sonic.Samples);
            if (den.Count == 0||dt.Count==0)
            {
                PetrelLogger.ErrorBox("NULL LOG found");
                return;
            }
            Console.WriteLine(den.Count);
            Console.WriteLine(dt.Count);

            int i;
            double startMD, endMD;
            int startden = 0,
                endden = 0,
                startdt = 0,
                enddt = 0;

            int count = 0;
            double interval1 = den[1].MD - den[0].MD;
            double interval2 = dt[1].MD - dt[0].MD;
            if (Math.Abs(interval1 - interval2) > 10e-4)
            {
                PetrelLogger.ErrorBox("DEPTH INTERVAL MISMATCH");
                return;
            }
            double interval = interval1;
                if (!(Math.Abs(den[0].MD - dt[0].MD) < 10e-4 && Math.Abs(den[den.Count - 1].MD - dt[dt.Count - 1].MD) < 10e-4))
                {
                    if (den[0].MD > dt[0].MD)
                        startMD = den[0].MD;
                    else
                        startMD = dt[0].MD;
                    if (den[den.Count - 1].MD > dt[dt.Count - 1].MD)
                        endMD = dt[dt.Count - 1].MD;
                    else
                        endMD = den[den.Count].MD;
                    for (int xxx = 0; xxx < den.Count; xxx++)
                    {
                        if (Math.Abs(den[xxx].MD - startMD) < 10e-4)
                            startden = xxx;
                        if (Math.Abs(den[xxx].MD - endMD) < 10e-4)
                            endden = xxx;
                    }
                    for (int xxx = 0; xxx < dt.Count; xxx++)
                    {
                        if (Math.Abs(dt[xxx].MD - startMD) < 10e-4)
                            startdt = xxx;
                        if (Math.Abs(dt[xxx].MD - endMD) < 10e-4)
                            enddt = xxx;
                    }
                    count = endden - startden + 1;
                }
                else
                {
                    count = den.Count;
                    startMD = den[0].MD;
                    endMD = den[den.Count - 1].MD;
                }

            float[] C2 = new float[count];
            float[] S2 = new float[count];
            float[] phi2 = new float[count];
            float[] error1 = new float[count];

            using (IProgress i1 = PetrelLogger.NewProgress(1, count))
            {
                for (i = 0; i < count; i++)
                {

                    float ac_imp;
                    if (den[i + startden].Value.ToString() == "NaN")
                    {
                        continue;
                    }
                    if (dt[i + startdt].Value.ToString() == "NaN")
                        continue;
                    float rho = den[i + startden].Value;
                    float son = dt[i + startdt].Value;
                    float Vinv = 1.0f / son;
                    ac_imp = rho * Vinv;
                    error1[i] = 1.0e35f;
                    for (float phi = (float)minPor; phi <= (float)(maxPor+0.1); phi += 0.1f)
                    {
                        for (float S = (float)minWater; S <= (float)(maxWater + 0.1); S += 0.1f)
                        {
                            for (float C = (float)minClay; C <= (float)(maxClay + 0.1); C += 0.1f)
                            {
                                double error = dfunc(ac_imp, rho, Vinv, C, S, phi);
                                if (error1[i] > (float)error)
                                {
                                    C2[i] = C;
                                    S2[i] = S;
                                    phi2[i] = phi;
                                    error1[i] = (float)error;

                                }
                            }
                        }
                    }
                    updateVals(ac_imp, rho, Vinv, ref C2[i], ref S2[i], ref phi2[i]);
                    i1.ProgressStatus = i + 1;
                }
            }
            b1 = density.Borehole;
            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs = PetrelSystem.PropertyVersionService;
                ILogTemplate glob = pvs.FindTemplateByMnemonics("Porosity");
                PropertyVersion pv = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                WellLogSample[] tsamples = new WellLogSample[count];
                for (int i2 = 0; i2 < count; i2++)
                {
                    double md = startMD + i2 * interval;
                    float val = phi2[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs = PetrelSystem.PropertyVersionService;
                ILogTemplate glob = pvs.FindTemplateByMnemonics(clayLog);
                PropertyVersion pv = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                WellLogSample[] tsamples = new WellLogSample[count];
                for (int i2 = 0; i2 < count; i2++)
                {
                    double md = startMD + i2 * interval;
                    float val = C2[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
            using (ITransaction trans = DataManager.NewTransaction())
            {
                IPropertyVersionService pvs = PetrelSystem.PropertyVersionService;
                ILogTemplate glob = pvs.FindTemplateByMnemonics(waterLog);

                PropertyVersion pv = pvs.FindOrCreate(glob);
                trans.Lock(b1);
                WellLog log = b1.Logs.CreateWellLog(pv);
                WellLogSample[] tsamples = new WellLogSample[count];
                for (int i2 = 0; i2 < count; i2++)
                {
                    double md = startMD + i2 * interval;
                    float val = S2[i2];
                    tsamples[i2] = new WellLogSample(md, val);
                }
                log.Samples = tsamples;
                trans.Commit();
            }
        }