public static IVTrace CalcSweep(CellSpec cell, double insolationW, double tempC) { double voc = cell.CalcVoc(insolationW, tempC); double isc = cell.CalcIsc(insolationW, tempC); int n = 100; double[] vecv = new double[n + 1]; for (int i = 0; i <= n; i++) { vecv[i] = voc * (double)i / n; } double[] veci = CalcIV(cell, vecv, insolationW, tempC); //Debug.Assert(Math.Abs(veci[0] - isc) < 0.001); //Debug.Assert(Math.Abs(veci[n]) < 0.001); double pmp = 0.0; double imp = 0.0, vmp = 0.0; for (int i = 0; i < n; i++) { double p = veci[i] * vecv[i]; if (p > pmp) { pmp = p; vmp = vecv[i]; imp = veci[i]; } } IVTrace trace = new IVTrace(); trace.I = veci; trace.V = vecv; trace.Isc = isc; trace.Voc = voc; trace.Imp = imp; trace.Vmp = vmp; return trace; }
private void Recalculate() { // recalc CellSpec spec = new CellSpec(); UpdateSpec(spec); // show sanity checks double i0 = spec.CalcI0(wattsIn, tempC); double isc = spec.CalcIsc(wattsIn, tempC); double voc = spec.CalcVoc(wattsIn, tempC); IVTrace sweep = CellSimulator.CalcSweep(spec, wattsIn, tempC); labelMaxPower.Text = string.Format( "Isc={0:0.000}A Voc={1:0.000}V @{2:0.00}C\n" + "Imp={3:0.000}A Vmp={4:0.000}V Pmp={5:0.000}W\n" + "Rev. sat. current {6:0.000}A, fill factor {7:0.0}%", isc, voc, tempC, sweep.Imp, sweep.Vmp, sweep.Pmp, i0, sweep.FillFactor * 100.0); // show an iv plot chartIV.X = sweep.V; chartIV.Y = sweep.I; }