public override int GetHashCode() { int hash = 1; if (Id != 0L) { hash ^= Id.GetHashCode(); } if (PokedexId != 0) { hash ^= PokedexId.GetHashCode(); } if (Cp != 0) { hash ^= Cp.GetHashCode(); } if (PercentHealth != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(PercentHealth); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public bool IsRegionModified(AMemory Memory, NvGpuBufferType BufferType, long PA, long Size) { bool[] Modified = Memory.IsRegionModified(PA, Size); if (Modified == null) { return(true); } ClearCachedPagesIfNeeded(); long PageSize = Memory.GetHostPageSize(); long Mask = PageSize - 1; long PAEnd = PA + Size; bool RegMod = false; int Index = 0; while (PA < PAEnd) { long Key = PA & ~Mask; long PAPgEnd = Math.Min((PA + PageSize) & ~Mask, PAEnd); bool IsCached = Cache.TryGetValue(Key, out CachedPage Cp); if (IsCached) { CpCount -= Cp.GetTotalCount(); SortedCache.Remove(Cp.Node); } else { Cp = new CachedPage(); Cache.Add(Key, Cp); } if (Modified[Index++] && IsCached) { Cp = new CachedPage(); Cache[Key] = Cp; } Cp.Node = SortedCache.AddLast(Key); RegMod |= Cp.AddRange(PA, PAPgEnd, BufferType); CpCount += Cp.GetTotalCount(); PA = PAPgEnd; } return(RegMod); }
public override int GetHashCode() { int hash = 1; if (PokemonId != 0) { hash ^= PokemonId.GetHashCode(); } if (Cp != 0) { hash ^= Cp.GetHashCode(); } if (WeightKg != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(WeightKg); } if (HeightM != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(HeightM); } if (PokemonLevel != 0) { hash ^= PokemonLevel.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private void AggregateOutputDir() { try { Cp.CopyDir(TaskOutputDirs, OutputDir); } catch (CopyClashException exception) { var buildTask1 = signatureToBuildTask[GetFileName(GetDirectoryName(exception.SourceDir1.AbsolutePath))]; var buildTask2 = signatureToBuildTask[GetFileName(GetDirectoryName(exception.SourceDir2.AbsolutePath))]; throw new Exception($"Tasks '{buildTask1.Name}' and '{buildTask2.Name}' are clashing. " + $"They produced the same file '{exception.FileRelPath}'."); } }
public override string ToString() { string returnString = ""; returnString += "T: " + EnginesGUI.GUIUnitsSettings.TemperatureUnits.Format(T); returnString += " P: " + EnginesGUI.GUIUnitsSettings.PressureUnits.Format(P); returnString += " Rho: " + Rho.ToString("F2"); returnString += "\n FF: " + FF.ToString("F3"); returnString += "\n Cp: " + Cp.ToString("F2"); returnString += " Cv: " + Cv.ToString("F2"); returnString += "\nGamma: " + Gamma.ToString("F2"); returnString += " R: " + R.ToString("F2"); return(returnString); }
private static void Main(string[] args) { Console.WriteLine("开始......"); string ProjectPath = ConfigurationManager.AppSettings.Get("ProjectPath"); Project Pj; List <Conmgr> Conmgrs; List <Package> Packages; Dictionary <int, EzOleDbConnectionManager> CMS; using (AutossisEntities db = new AutossisEntities()) { Pj = db.Project.Where(p => p.ProjectName == projectName).First(); Conmgrs = db.Conmgr.Where(p => p.ProjectId == Pj.ProjectId).ToList(); Packages = db.Package.Where(p => p.ProjectId == Pj.ProjectId).ToList(); CMS = getOledbConnectionManagers(Conmgrs); } ConventionBuilder conventions = new ConventionBuilder(); conventions .ForTypesDerivedFrom <ICreatePackage>() .Export <ICreatePackage>() .Shared(); Assembly[] assemblies = new[] { typeof(Program).GetTypeInfo().Assembly }; ContainerConfiguration configuration = new ContainerConfiguration() .WithAssemblies(assemblies, conventions); ICreatePackage Cp; using (CompositionHost container = configuration.CreateContainer()) { Cp = container.GetExport <ICreatePackage>(ConfigurationManager.AppSettings.Get("ProjectType")); Cp.ezOleDbConnectionManagers = CMS; } foreach (Package package in Packages) { ez.AddPackage(Cp.Create(package)); Console.WriteLine(package.PackageName + " 生成成功。"); } JobControl(Pj, null); ez.SaveTo(ProjectPath + Pj.ProjectName + ".ispac"); Console.WriteLine("全部成功!"); Console.ReadKey(); }
public string this[string columnName] { get { string errormsg = null; switch (columnName) { case "Cp": if (string.IsNullOrEmpty(Cp.ToString())) { errormsg = "Введите условную прибыль"; } break; } return(errormsg); } }
public void TestInterpolation() { const string fromName = "from1"; const string fromText = "<from>"; const string toName = "to2"; const string toText = "<to>"; var mockCore = MockRepository.GenerateMock <ICentipedeCore>(); var mockVariables = MockRepository.GenerateMock <IDictionary <string, object> >(); var mockPythonEngine = MockRepository.GenerateStub <IPythonEngine>(); mockCore.Expect(c => c.PythonEngine).Return(mockPythonEngine); var bcFrom = MockRepository.GenerateMock <IPythonByteCode>(); var bcTo = MockRepository.GenerateMock <IPythonByteCode>(); mockPythonEngine.Expect(e => e.Compile(Arg <String> .Is.Equal(fromText), Arg <SourceCodeType> .Is.Anything)) .Return(bcFrom); mockPythonEngine.Expect(e => e.Evaluate(bcFrom)) .Return(fromName); mockPythonEngine.Expect(e => e.Compile(Arg <String> .Is.Equal(toText), Arg <SourceCodeType> .Is.Anything)) .Return(bcTo); mockPythonEngine.Expect(e => e.Evaluate(bcTo)).Return(toName); var action = new Cp(mockVariables, mockCore) { From = string.Format("{{{0}}}", fromText), To = string.Format("{{{0}}}", toText) }; using (new FileForTesting(fromName)) using (new FileForTesting(toName, create: false)) { action.Run(); } mockPythonEngine.VerifyAllExpectations(); }
public Cp[] GetProduct() { DataTable table = new DataTable(); string sql = "select * from cp"; table = SBS.DBOP.GetDataTable(sql); Cp[] cp = new Cp[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { cp[i] = new Cp { lx = table.Rows[i]["lx"].ToString().Trim(), pm1 = table.Rows[i]["pm1"].ToString().Trim(), pm2 = table.Rows[i]["pm2"].ToString().Trim(), color = table.Rows[i]["color"].ToString().Trim(), }; } return(cp); }
public override int GetHashCode() { int hash = 1; if (Id != 0L) { hash ^= Id.GetHashCode(); } if (PokedexId != 0) { hash ^= PokedexId.GetHashCode(); } if (Cp != 0) { hash ^= Cp.GetHashCode(); } if (PercentHealth != 0F) { hash ^= PercentHealth.GetHashCode(); } return(hash); }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("nominal", Nominal.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("mean", Mean.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("standardDeviation", StandardDeviation.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("lowerSpecLimit", LowerSpecLimit.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("upperSpecLimit", UpperSpecLimit.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("cp", Cp.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("cpk", Cpk.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("distribution", Distribution); writer.WriteAttributeString("skewness", Skewness.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("kurtosis", Kurtosis.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("sampleSize", SampleSize.ToString(CultureInfo.InvariantCulture)); writer.WriteStartElement("Sample"); Sample.WriteXml(writer); writer.WriteEndElement(); writer.WriteStartElement("Estimate"); Estimate.WriteXml(writer); writer.WriteEndElement(); }
public void TestMissingFile() { var mockCore = MockRepository.GenerateMock <ICentipedeCore>(); var mockVariables = MockRepository.GenerateMock <IDictionary <string, object> >(); const string fromName = "fromow"; const string toName = "toow"; Cp action = new Cp(mockVariables, mockCore) { From = fromName, To = toName, AllowOverWrite = false }; try { action.Run(); Assert.Fail("Did not fail with missing file"); } catch { } }
public void TestOverwrite() { var mockCore = MockRepository.GenerateMock <ICentipedeCore>(); var mockVariables = MockRepository.GenerateMock <IDictionary <string, object> >(); const string fromName = "fromow"; const string toName = "toow"; Cp action = new Cp(mockVariables, mockCore) { From = fromName, To = toName, AllowOverWrite = false }; using (new FileForTesting(fromName)) using (new FileForTesting(toName)) { try { action.Run(); Assert.Fail("Did not fail when not overwriting"); } catch { } action.AllowOverWrite = true; try { action.Run(); } catch { Assert.Fail("Failed to overwrite"); } } }
public void TestRun() { var mockCore = MockRepository.GenerateMock <ICentipedeCore>(); var mockVariables = MockRepository.GenerateMock <IDictionary <string, object> >(); const string fromName = "from"; const string toName = "to"; Cp action = new Cp(mockVariables, mockCore) { From = fromName, To = toName }; const int length = 1024; using (new FileForTesting(fromName, length)) using (new FileForTesting(toName, create: false)) { action.Run(); Assert.IsTrue(File.Exists(toName)); Assert.AreEqual(File.ReadAllText(toName).Length, length); } }
//P_ref is a vector of power refenreces for tehe wind turbine with dimension 1xN //v_nac is a vector of wind speed at each wind turbine with dimension 1xN //P_demand is a scale of the wind farm power demand. //parm is a struct of wind turbine parameters e.g. NREL5MW #endregion internal static void powerDistributionControl(out ILArray <double> P_ref, out ILArray <double> P_a, double[] v_nac, double P_demand, WindTurbineParameters parm) { #region "Used variables declaration" double rho; ILArray <double> R; ILArray <double> rated; ILArray <double> Cp; int i; #endregion rho = parm.rho; //air density for each wind turbine(probably the same for all) R = parm.radius.C; //rotor radius for each wind turbine(NREL.r=63m) rated = parm.rated.C; //Rated power for each wind turbine(NREL.Prated=5MW) Cp = parm.Cp.C; // Max cp of the turbines for each wind turbine(NREL.Cp.max=0.45) P_a = zeros(parm.N, 1); P_ref = zeros(parm.N, 1); // Compute available power at each turbine for (i = 1; i <= parm.N; i++) { P_a._(i, '=', min_(__[rated._(i), (pi / 2) * rho * _p(R._(i), 2) * _p(v_nac[i - 1], 3) * Cp._(i)])); } var sum_P_a_ = sum_(P_a); //Distribute power according to availibility for (i = 1; i <= parm.N; i++) { if (P_demand < sum_P_a_) { P_ref._(i, '=', max_(__[0, min_(__[rated._(i), P_demand * P_a._(i) / sum_P_a_])])); } else { P_ref._(i, '=', P_a._(i)); } } }
private static void LoadContants() { Cp.Init(); Hp.Init(); }
//P_ref is a vector of power refenreces for tehe wind turbine with dimension 1xN //v_nac is a vector of wind speed at each wind turbine with dimension 1xN //P_demand is a scale of the wind farm power demand. //parm is a struct of wind turbine parameters e.g. NREL5MW public static void DistributePower(ILArray <double> v_nac, double P_demand, ILArray <double> Power, WindTurbineParameters parm, out ILArray <double> P_ref, out ILArray <double> P_a) { double rho; ILArray <double> R; ILArray <double> rated; int N; ILArray <double> Cp; double P_avail; rho = parm.rho; //air density for each wind turbine(probably the same for all) R = parm.radius.C; //rotor radius for each wind turbine(NREL.r=63m) rated = parm.rated.C; //Rated power for each wind turbine(NREL.Prated=5MW) N = parm.N; //Number of turbines in windfarm Cp = parm.Cp.C; // Max cp of the turbines for each wind turbine(NREL.Cp.max=0.45) P_a = ILMath.zeros(N, 1); P_ref = ILMath.zeros(N, 1); // Compute available power at each turbine for (var i = 0; i <= N - 1; i++) { //P_a=A*pi*r*r*Cp*v*v*v P_a[i] = Math.Min(rated.GetValue(i), (ILMath.pi / 2) * rho * Math.Pow(R.GetValue(i), 2) * Math.Pow(v_nac.GetValue(i), 3) * Cp.GetValue(i)); } //Compute total available power P_avail = (double)ILMath.sum(P_a); //Distribute power according to availibility for (var i = 0; i <= N - 1; i++) { if (P_demand < P_avail) { P_ref[i] = Math.Max(0, Math.Min(rated.GetValue(i), P_demand * P_a.GetValue(i) / P_avail)); } else { P_ref[i] = P_a.GetValue(i); } } }
public override int GetHashCode() { int hash = 1; if (Id != 0UL) { hash ^= Id.GetHashCode(); } if (PokemonId != 0) { hash ^= PokemonId.GetHashCode(); } if (Cp != 0) { hash ^= Cp.GetHashCode(); } if (Stamina != 0) { hash ^= Stamina.GetHashCode(); } if (StaminaMax != 0) { hash ^= StaminaMax.GetHashCode(); } if (Move1 != 0) { hash ^= Move1.GetHashCode(); } if (Move2 != 0) { hash ^= Move2.GetHashCode(); } if (DeployedFortId.Length != 0) { hash ^= DeployedFortId.GetHashCode(); } if (OwnerName.Length != 0) { hash ^= OwnerName.GetHashCode(); } if (IsEgg != false) { hash ^= IsEgg.GetHashCode(); } if (EggKmWalkedTarget != 0D) { hash ^= EggKmWalkedTarget.GetHashCode(); } if (EggKmWalkedStart != 0D) { hash ^= EggKmWalkedStart.GetHashCode(); } if (Origin != 0) { hash ^= Origin.GetHashCode(); } if (HeightM != 0F) { hash ^= HeightM.GetHashCode(); } if (WeightKg != 0F) { hash ^= WeightKg.GetHashCode(); } if (IndividualAttack != 0) { hash ^= IndividualAttack.GetHashCode(); } if (IndividualDefense != 0) { hash ^= IndividualDefense.GetHashCode(); } if (IndividualStamina != 0) { hash ^= IndividualStamina.GetHashCode(); } if (CpMultiplier != 0F) { hash ^= CpMultiplier.GetHashCode(); } if (Pokeball != 0) { hash ^= Pokeball.GetHashCode(); } if (CapturedCellId != 0UL) { hash ^= CapturedCellId.GetHashCode(); } if (BattlesAttacked != 0) { hash ^= BattlesAttacked.GetHashCode(); } if (BattlesDefended != 0) { hash ^= BattlesDefended.GetHashCode(); } if (EggIncubatorId.Length != 0) { hash ^= EggIncubatorId.GetHashCode(); } if (CreationTimeMs != 0UL) { hash ^= CreationTimeMs.GetHashCode(); } if (NumUpgrades != 0) { hash ^= NumUpgrades.GetHashCode(); } if (AdditionalCpMultiplier != 0F) { hash ^= AdditionalCpMultiplier.GetHashCode(); } if (Favorite != 0) { hash ^= Favorite.GetHashCode(); } if (Nickname.Length != 0) { hash ^= Nickname.GetHashCode(); } if (FromFort != 0) { hash ^= FromFort.GetHashCode(); } if (BuddyCandyAwarded != 0) { hash ^= BuddyCandyAwarded.GetHashCode(); } if (BuddyTotalKmWalked != 0F) { hash ^= BuddyTotalKmWalked.GetHashCode(); } if (DisplayPokemonId != 0) { hash ^= DisplayPokemonId.GetHashCode(); } if (DisplayCp != 0) { hash ^= DisplayCp.GetHashCode(); } return(hash); }
//% The main file for running the wind farm controll and wake simulation. // It is not completely done yet. Further updates will come // Currently there are only 4 turbines, for test purposes. But is should be // easily updated to a larger number of turbines. // Similarly there is a lot of room for speed optimizations, even though it // now runs slowly with only 4 turbines // 19/07-13 MS public static double[][] Simulation(WakeFarmControlConfig config) { var parm = new WindTurbineParameters(); ILMatFile env; ILMatFile wt; ILArray <int> idx; ILArray <double> ee; double Ki; double Kp; int PC_MaxPit; int PC_MinPit; double VS_CtInSp; double VS_RtGnSp; double VS_Rgn2K; double omega0; double beta0; double power0; ILArray <double> x; ILArray <double> u0; ILArray <double> u; ILArray <double> Mg_old; ILArray <double> P_ref; ILArray <double> Pa; ILArray <double> Power; ILArray <double> Ct; ILArray <double> P_ref_new; ILArray <double> v_nac; double alpha; double Mg_max_rate; ILArray <double> e; ILArray <double> Mg; ILArray <double> beta; ILArray <double> Cp; ILArray <double> Omega; ILArray <double> out_; if (config.NTurbines == 0) { return(null); } // Wind farm properties //turbine properties env = wt = new ILMatFile(config.NREL5MW_MatFile); //Load parameters from the NREL 5MW turbine parm.N = config.NTurbines; // number of turbines in farm parm.rho = (double)env.GetArray <double>("env_rho"); //air density parm.radius = ((double)(wt.GetArray <double>("wt_rotor_radius"))) * ILMath.ones(1, config.NTurbines); // rotor radius (NREL5MW) parm.rated = 5e6 * ILMath.ones(1, config.NTurbines); //rated power (NREL5MW) parm.ratedSpeed = (double)wt.GetArray <double>("wt_rotor_ratedspeed"); //rated rotor speed idx = ILMath.empty <int>(); ILMath.max(wt.GetArray <double>("wt_cp_table")[ILMath.full], idx); //Find index for max Cp; parm.Cp = ILMath.ones(1, config.NTurbines) * wt.GetArray <double>("wt_cp_table").GetValue(idx.ToArray()); //Set power coefficent to maximum value in the cp table parm.Ct = ILMath.ones(1, config.NTurbines) * wt.GetArray <double>("wt_ct_table").GetValue(idx.ToArray()); //Set power coefficent to maximum value in the ct table // NOTE: controller parameters should be imported from the wt....struct in //Pitch control ee = 0; //blade pitch integrator Ki = 0.008068634 * 360 / 2 / ILMath.pi; // integral gain (NREL5MW) Kp = 0.01882681 * 360 / 2 / ILMath.pi; // proportional gain (NREL5MW) PC_MaxPit = 90; PC_MinPit = 0; //region control NREL VS_CtInSp = 70.16224; VS_RtGnSp = 121.6805; VS_Rgn2K = 2.332287; // load initial wind data var wind = new ILMatFile(config.Wind_MatFile); //% Set initial conditions omega0 = 1.267; //Rotation speed beta0 = 0; //Pitch var timeLine = (int)config.TimeLine(); power0 = parm.rated.GetValue(0); //Power production x = (omega0 * ILMath.ones(parm.N, 1)).Concat((wind.GetArray <double>("wind").GetValue(0, 1) * ILMath.ones(parm.N, 1)), 1); u0 = (beta0 * ILMath.ones(parm.N, 1)).Concat((power0 * ILMath.ones(parm.N, 1)), 1); u = u0.C; Mg_old = u[ILMath.full, 1]; P_ref = ILMath.zeros(parm.N, (int)config.TimeLine()); //Initialize matrix to save the power production history for each turbine Pa = P_ref.C; //Initialize available power matrix Power = P_ref.C; Ct = parm.Ct.C; //Initialize Ct - is this correct? Ct[timeLine - 1, ILMath.full] = Ct[0, ILMath.full]; P_ref_new = power0 * ILMath.ones(config.NTurbines, 1); v_nac = ILMath.zeros(Ct.Size[1], timeLine); Mg = ILMath.zeros(u.Size[0], timeLine); beta = ILMath.zeros(u.Size[0], timeLine); Omega = ILMath.zeros(Ct.Size[1], timeLine); Cp = ILMath.zeros(timeLine, parm.Cp.Size[1]); var turbineModel = new TurbineDrivetrainModel(); //% Simulate wind farm operation //var timeLine = (int) config.TimeLine(); for (var i = 2; i <= timeLine; i++) //At each sample time(DT) from Tstart to Tend { //Calculate the wake using the current Ct values { ILArray <double> out_v_nac; WakeCalculation.Calculate((Ct[i - 1 - 1, ILMath.full]), i, wind, out out_v_nac); v_nac[ILMath.full, i - 1] = out_v_nac; } x[ILMath.full, 1] = v_nac[ILMath.full, i - 1]; //Farm control //Calculate the power distribution references for each turbine if (config.EnablePowerDistribution) { ILArray <double> out_Pa; PowerDistributionControl.DistributePower(v_nac[ILMath.full, i - 1], config.Pdemand, Power[ILMath.full, i - 1 - 1], parm, out P_ref_new, out out_Pa); Pa[ILMath.full, i - 1] = out_Pa; } //Hold the demand for some seconds if (ILMath.mod(i, ILMath.round(config.PRefSampleTime / config.DT)) == 2) //??? { P_ref[ILMath.full, i - 1] = P_ref_new; } else { if (config.PowerRefInterpolation) { alpha = 0.01; P_ref[ILMath.full, i - 1] = (1 - alpha) * P_ref[ILMath.full, i - 1 - 1] + (alpha) * P_ref_new; } else { P_ref[ILMath.full, i - 1] = P_ref_new; } } //Calculate control for each individual turbine - should be moved to the //turbine (drivetrain) model. //Torque controller for (var j = 1; j <= parm.N; j++) { if ((x.GetValue(j - 1, 0) * 97 >= VS_RtGnSp) || (u.GetValue(j - 1, 0) >= 1)) // We are in region 3 - power is constant { u.SetValue(P_ref.GetValue(j - 1, i - 1) / x.GetValue(j - 1, 0), j - 1, 1); } else if (x.GetValue(j - 1, 0) * 97 <= VS_CtInSp) //! We are in region 1 - torque is zero { u.SetValue(0.0, j - 1, 1); } else //! We are in region 2 - optimal torque is proportional to the square of the generator speed { u.SetValue(97 * VS_Rgn2K * x.GetValue(j - 1, 0) * x.GetValue(j - 1, 0) * Math.Pow(97, 2), j - 1, 1); } } //Rate limit torque change // u(:,2) - Mg_old; Mg_max_rate = 1e6 * config.DT; u[ILMath.full, 1] = ILMath.sign(u[ILMath.full, 1] - Mg_old) * ILMath.min(ILMath.abs(u[ILMath.full, 1] - Mg_old), Mg_max_rate) + Mg_old; //Pitch controller e = 97 * (omega0 * ILMath.ones(parm.N, 1) - x[ILMath.full, 0]); ee = ee - config.DT * e; ee = ILMath.min(ILMath.max(ee, PC_MinPit / Ki), PC_MaxPit / Ki); u[ILMath.full, 0] = -Kp * config.DT * e + Ki * ee; for (var j = 1; j <= parm.N; j++) { u.SetValue(Math.Min(Math.Max(u.GetValue(j - 1, 0), PC_MinPit), PC_MaxPit), j - 1, 0); } if (!config.EnableTurbineDynamics) { u = u0; } Mg[ILMath.full, i - 1] = u[ILMath.full, 1]; Mg_old = Mg[ILMath.full, i - 1]; beta[ILMath.full, i - 1] = u[ILMath.full, 0]; //Set pitch //Turbine dynamics - can be simplified if (config.EnableTurbineDynamics) { for (var j = 1; j <= parm.N; j++) { double out_x; double out_Ct; double out_Cp; turbineModel.Model(x[j - 1, ILMath.full], u[j - 1, ILMath.full], wt, env, config.DT, out out_x, out out_Ct, out out_Cp); x.SetValue(out_x, j - 1, 0); Ct.SetValue(out_Ct, i - 1, j - 1); Cp.SetValue(out_Cp, i - 1, j - 1); } } else { Ct[i - 1, ILMath.full] = parm.Ct; Cp[i - 1, ILMath.full] = parm.Cp; x[ILMath.full, 0] = parm.ratedSpeed;//Rotational speed } Omega[ILMath.full, i - 1] = x[ILMath.full, 0]; Power[ILMath.full, i - 1] = Omega[ILMath.full, i - 1] * Mg[ILMath.full, i - 1]; } //% Save output data out_ = (config.DT * (ILMath.counter(0, 1, config.TimeLine()))); out_ = out_.Concat(v_nac.T, 1); out_ = out_.Concat(Omega.T, 1); out_ = out_.Concat(beta.T, 1); out_ = out_.Concat(P_ref.T, 1); out_ = out_.Concat(Ct, 1); out_ = out_.Concat(Cp, 1); out_ = out_.Concat(Pa.T, 1); out_ = out_.Concat(Mg.T, 1); out_ = out_.Concat(Power.T, 1); //Ttotal power demand var l = config.NTurbines * 3 + 1; var r = l + config.NTurbines - 1; out_ = out_.Concat(ILMath.sum(out_[ILMath.full, ILMath.r(l, r)], 1) / 1e6, 1); // P_ref sum l = config.NTurbines * 6 + 1; r = l + config.NTurbines - 1; out_ = out_.Concat(ILMath.sum(out_[ILMath.full, ILMath.r(l, r)], 1) / 1e6, 1); // Pa sum. 'Power Demand' out_ = out_.Concat(ILMath.sum(Power).T / 1e6, 1); // 'Actual Production' //Ttotal power demand out_ = out_.Concat(ILMath.sum(P_ref.T, 1), 1); // 'Demand' out_ = out_.Concat(ILMath.sum(Pa.T, 1), 1); // 'Available' out_ = out_.Concat(ILMath.sum(Mg * Omega).T, 1); // 'Actual' //Total power produced out_ = out_.Concat((Mg * Omega).T, 1); var out_doubleArray = new double[out_.Size[0]][]; for (int i = 0; i <= out_doubleArray.GetLength(0) - 1; i++) { out_doubleArray[i] = new double[out_.Size[1]]; for (int j = 0; j <= out_doubleArray[i].GetLength(0) - 1; j++) { out_doubleArray[i][j] = out_.GetValue(i, j); } } return(out_doubleArray); }
public bool IsRegionModified(AMemory Memory, NvGpuBufferType BufferType, long PA, long Size) { (bool[] Modified, long ModifiedCount) = Memory.IsRegionModified(PA, Size); PA = Memory.GetPhysicalAddress(PA); ClearCachedPagesIfNeeded(); long PageSize = AMemory.PageSize; EnsureResidencyInitialized(PageSize); bool HasResidents = AddResidency(PA, Size); if (!HasResidents && ModifiedCount == 0) { return(false); } long Mask = PageSize - 1; long ResidencyKey = PA; long PAEnd = PA + Size; bool RegMod = false; int Index = 0; while (PA < PAEnd) { long Key = PA & ~AMemory.PageMask; long PAPgEnd = Math.Min((PA + AMemory.PageSize) & ~AMemory.PageMask, PAEnd); bool IsCached = Cache.TryGetValue(Key, out CachedPage Cp); if (IsCached) { CpCount -= Cp.GetTotalCount(); SortedCache.Remove(Cp.Node); } else { Cp = new CachedPage(); Cache.Add(Key, Cp); } if (Modified[Index++] && IsCached) { Cp = new CachedPage(); Cache[Key] = Cp; } Cp.AddResidency(ResidencyKey); Cp.Node = SortedCache.AddLast(Key); RegMod |= Cp.AddRange(PA, PAPgEnd, BufferType); CpCount += Cp.GetTotalCount(); PA = PAPgEnd; } return(RegMod); }