public string getText(int timei = -1) { List <OutComp> outcomps; string s = ""; if (timei >= 0) { outcomps = timeOutSet[timei].comps; } else { outcomps = outSet.comps; } if (outcomps.Count > 0) { OutComp prevComp = null; float rs = 0; ControlComp comp0 = new ControlComp(outcomps[0]); s += "<b>Label\tK\tM\tCon\tPhase\tRet (max)\tRet (avg)\tWidth\tSigma\tHeight\tPurity\tRecovery\tResolution</b>\n"; s += string.Format("<b>\t\t{0}\t{1}\t\t{2}\t{2}\t{2}\t{2}\t{1}\t\t\t</b>\n", comp0.MassUnits, comp0.ConcentrationUnits, comp0.Units, comp0.Units, comp0.Units); foreach (OutComp comp in outcomps) { s += comp.label + "\t"; s += string.Format("{0}\t", comp.k); s += string.Format("{0}\t", comp.m); s += string.Format("{0:0.0#E+0}\t", comp.concentration); s += string.Format("{0}\t", comp.phase); s += string.Format("{0:0.0#}\t", comp.retention); s += string.Format("{0:0.0#}\t", comp.average); s += string.Format("{0:0.0#}\t", comp.width); s += string.Format("{0:0.0#}\t", comp.sigma); s += string.Format("{0:0.0#E+0}\t", comp.height); s += string.Format("{0:0.0%}\t", comp.purity); s += string.Format("{0:0.0%}\t", comp.recovery); if (prevComp != null) { rs = Equations.calcRes(prevComp, comp); if (rs != 0) { s += string.Format("{0:0.000#}", rs); } else { s += "-"; } } s += "\n"; prevComp = comp; } } return(s); }
public void updateControlComp() { float sel = comp1.k / comp2.k; float rs = Equations.calcRes(comp1, comp2); labelText.Text = String.Format("{0}, {1}", comp1.label, comp2.label); kText.Text = String.Format("{0}, {1}", comp1.k, comp2.k); selText.Text = String.Format("{0:0.000}", sel); if (rs != 0) { rsText.Text = String.Format("{0:0.000}", rs); } else { rsText.Text = "-"; } }
public VisOutSet updateVisOutVar(OutSet outSet, ViewParams viewParams) { VisOutSet visOutSet = new VisOutSet(); List <VisSerie> visSeries; List <VisSerie> visRawSeries = null; VisSerie visSerie; List <VisPoint> visPoints; OutCell[][] rawOutCells = outSet.rawOutCells; OutCell[] compRawOutCells; OutCell outCell; OutComp outComp; VisComp visComp; VisAxes visAxes = new VisAxes(); VisAxis visAxis; Axes axes = outSet.axes; Axis xaxis = new Axis(); Axis yaxis = new Axis(); PhaseType phase = new PhaseType(); int nphases; int ncomps; int npoints; int nseries; int ncells; bool previewMode = (viewParams.viewType == ViewType.Setup); bool dispDualTime = (viewParams.phaseDisplay == PhaseDisplayType.UpperLowerTime); bool dispDual = (viewParams.phaseDisplay == PhaseDisplayType.UpperLower || dispDualTime); bool usePrefixes = (viewParams.exponentType == ExponentType.Prefixes); bool scaleDrawReverse; bool scaleSet; bool sum; float maxcon = 0; float con = 0; float rangey = 0; float rangex = 0; float range; float rangey0; float scaleu, scalel; float miny, maxy; float minvx = 0; float maxvx = 0; float minxlabel = 0; float maxxlabel = 0; float k; float flow; float pos; float vceff; RectangleF allrect = new RectangleF(0, 0, 1, 1); RectangleF vrect = allrect; RectangleF rawvrect = allrect; float unitsize = 0.025f; float vx, vy; int s = 0; int c; string label = ""; MassUnitsType prefMassUnits = inParams.massUnits; int prefMassUnitsi; float multiplier = 1; // general vars if (dispDual && !previewMode) { nphases = 2; } else { nphases = 1; } ncomps = inParams.comps.Count; nseries = outSet.outCells.Length; if (ncomps == 0) { return(visOutSet); } // update outComps units foreach (OutComp outComp0 in outSet.comps) { outComp0.units = inParams.viewUnits; outComp0.volUnits = inParams.volUnits; outComp0.timeUnits = inParams.timeUnits; outComp0.massUnits = inParams.massUnits; } // convert out to units outSet.unitsOutCells = new OutCell[outSet.outCells.Length][]; for (s = 0; s < nseries; s++) { c = s / nphases; if (viewParams.phaseDisplay == PhaseDisplayType.Lower) { phase = PhaseType.Lower; } else { phase = PhaseType.Upper; } if (nphases > 1) { phase = (PhaseType)((s % nphases) + 1); } ncells = outSet.outCells[s].Length; outSet.unitsOutCells[s] = new OutCell[ncells]; for (int i = 0; i < ncells; i++) { pos = inParams.convertUnit(outSet.outCells[s][i].pos, inParams.natUnits, viewParams.viewUnits, phase); con = outSet.outCells[s][i].con; outSet.unitsOutCells[s][i] = new OutCell(pos, con); } } // initialise vis series visSeries = new List <VisSerie>(nseries); if (viewParams.showProbUnits) { visRawSeries = new List <VisSerie>(nseries); } if (viewParams.showProbUnits) { if (dispDual) { rawvrect.Height = unitsize * 2; } else { rawvrect.Height = unitsize; } vrect.Y = rawvrect.Bottom; vrect.Height = 1 - vrect.Y; } // Axes axes = outSet.axes; // Set maxcon / rangey if (viewParams.yScale == YScaleType.Absolute) { // * not exactly correct; should use maxcon from first (time) step maxcon = 0; for (int i = 0; i < outSet.comps.Count; i++) { if (outSet.comps[i].m > maxcon) { maxcon = outSet.comps[i].m; } } rangey = maxcon; } else if (viewParams.yScale == YScaleType.Normalised) { rangey = 0; } else // Auto or Log scale { maxcon = 0; for (int i = 0; i < axes.maxcon.Count; i++) { if (axes.maxcon[i] > maxcon) { maxcon = axes.maxcon[i]; } } if (viewParams.yScale == YScaleType.Automatic) { rangey = maxcon; } else if (axes.logScale) { maxcon = (float)Math.Ceiling(Math.Log(maxcon)); // Nearest E power rangey = 5; // Scale: E^maxcon ... E^(maxcon-rangey) } } // Column lines if (viewParams.showProbUnits) { visAxis = new VisAxis(); visAxis.drawColor = Colors.LightGray; visAxis.point1 = new VisPoint(vrect.Left, rawvrect.Top); visAxis.point2 = new VisPoint(vrect.Left, rawvrect.Bottom); visAxes.visAxes.Add(visAxis); visAxis = new VisAxis(); visAxis.drawColor = Colors.LightGray; visAxis.point1 = new VisPoint(vrect.Right, rawvrect.Top); visAxis.point2 = new VisPoint(vrect.Right, rawvrect.Bottom); visAxes.visAxes.Add(visAxis); visAxis = new VisAxis(); visAxis.point1 = new VisPoint(vrect.Left, rawvrect.Top); visAxis.point2 = new VisPoint(vrect.Right, rawvrect.Top); visAxes.visAxes.Add(visAxis); visAxis = new VisAxis(); visAxis.point1 = new VisPoint(vrect.Left, rawvrect.Bottom); visAxis.point2 = new VisPoint(vrect.Right, rawvrect.Bottom); visAxes.visAxes.Add(visAxis); } if (axes.showCol) { visAxis = new VisAxis(); visAxis.drawColor = Colors.LightGray; vx = axes.colstart / axes.rangex * allrect.Width + allrect.Left; visAxis.point1 = new VisPoint(vx, allrect.Top); visAxis.point2 = new VisPoint(vx, allrect.Bottom); visAxes.visAxes.Add(visAxis); visAxis = new VisAxis(); visAxis.drawColor = Colors.LightGray; vx = axes.colend / axes.rangex * allrect.Width + allrect.Left; visAxis.point1 = new VisPoint(vx, allrect.Top); visAxis.point2 = new VisPoint(vx, allrect.Bottom); visAxes.visAxes.Add(visAxis); } if (axes.showDeadvolstart) { visAxis = new VisAxis(); vx = axes.deadvolstart / axes.rangex * vrect.Width + vrect.Left; visAxis.point1 = new VisPoint(vx, vrect.Top); visAxis.point2 = new VisPoint(vx, vrect.Bottom); visAxes.visAxes.Add(visAxis); } if (axes.showDeadvolend) { visAxis = new VisAxis(); vx = axes.deadvolend / axes.rangex * vrect.Width + vrect.Left; visAxis.point1 = new VisPoint(vx, vrect.Top); visAxis.point2 = new VisPoint(vx, vrect.Bottom); visAxes.visAxes.Add(visAxis); } if (axes.showDeadvolinsert) { visAxis = new VisAxis(); vx = axes.deadvolinjectstart / axes.rangex * vrect.Width + vrect.Left; visAxis.point1 = new VisPoint(vx, vrect.Top); visAxis.point2 = new VisPoint(vx, vrect.Bottom); visAxes.visAxes.Add(visAxis); visAxis = new VisAxis(); vx = axes.deadvolinjectend / axes.rangex * vrect.Width + vrect.Left; visAxis.point1 = new VisPoint(vx, vrect.Top); visAxis.point2 = new VisPoint(vx, vrect.Bottom); visAxes.visAxes.Add(visAxis); } // X Axis if (viewParams.syncScales && viewParams.viewUnits != QuantityType.ReS) { minxlabel = inParams.convertUnit(axes.scaleminulabel, inParams.natUnits, viewParams.viewUnits, PhaseType.Upper); maxxlabel = inParams.convertUnit(axes.scalemaxulabel, inParams.natUnits, viewParams.viewUnits, PhaseType.Upper); scaleu = Math.Abs(maxxlabel - minxlabel); minxlabel = inParams.convertUnit(axes.scaleminllabel, inParams.natUnits, viewParams.viewUnits, PhaseType.Lower); maxxlabel = inParams.convertUnit(axes.scalemaxllabel, inParams.natUnits, viewParams.viewUnits, PhaseType.Lower); scalel = Math.Abs(maxxlabel - minxlabel); if (scaleu != 0 && scalel != 0) { axes.sync(scaleu, scalel); } } label = ""; for (int phasei = 0; phasei < 2; phasei++) { if (dispDual) { vy = vrect.Top + 0.5f * vrect.Height; scaleDrawReverse = ((PhaseType)(phasei + 1) == PhaseType.Lower); } else { vy = vrect.Bottom; scaleDrawReverse = false; } scaleSet = false; if ((PhaseType)(phasei + 1) == PhaseType.Upper && (inParams.runMode != RunModeType.LowerPhase || (inParams.eeMode != EEModeType.None && inParams.isPosEEdir())) && viewParams.phaseDisplay != PhaseDisplayType.Lower) { // show Up axis minvx = vrect.Left + axes.scaleminu / axes.rangexu * vrect.Width; maxvx = vrect.Left + axes.scalemaxu / axes.rangexu * vrect.Width; minxlabel = inParams.convertUnit(axes.scaleminulabel, inParams.natUnits, viewParams.viewUnits, PhaseType.Upper); maxxlabel = inParams.convertUnit(axes.scalemaxulabel, inParams.natUnits, viewParams.viewUnits, PhaseType.Upper); rangex = Math.Abs(axes.scalemaxu - axes.scaleminu); scaleSet = true; } else if ((PhaseType)(phasei + 1) == PhaseType.Lower && (inParams.runMode != RunModeType.UpperPhase || (inParams.eeMode != EEModeType.None && !inParams.isPosEEdir())) && viewParams.phaseDisplay != PhaseDisplayType.Upper) { // show Lp axis minvx = vrect.Left + axes.scaleminl / axes.rangexl * vrect.Width; maxvx = vrect.Left + axes.scalemaxl / axes.rangexl * vrect.Width; minxlabel = inParams.convertUnit(axes.scaleminllabel, inParams.natUnits, viewParams.viewUnits, PhaseType.Lower); maxxlabel = inParams.convertUnit(axes.scalemaxllabel, inParams.natUnits, viewParams.viewUnits, PhaseType.Lower); rangex = Math.Abs(axes.scalemaxl - axes.scaleminl); scaleSet = true; } if (scaleSet) { range = maxxlabel - minxlabel; // if syncScales: use same divs/stepsize as other axis if (phasei == 0 || !viewParams.syncScales || viewParams.phaseDisplay == PhaseDisplayType.Upper || viewParams.phaseDisplay == PhaseDisplayType.Lower) { xaxis.calcScale(range); } if (label == "") { // only do first label label = inParams.getXaxisLegend(); } else { label = ""; } visAxes.addAxis(label, minvx, vy, maxvx, vy, false, true, true, !previewMode, !dispDual, scaleDrawReverse, false, false, 1, Colors.Black, 1, minxlabel, maxxlabel, xaxis.nMajorDivs, xaxis.majorStepSize, xaxis.nMinorDivs, xaxis.minorStepSize); if (viewParams.viewUnits == QuantityType.ReS) { // ReS (K-values) scale: overwrite labels visAxis = visAxes.visAxes[visAxes.visAxes.Count - 1]; visAxis.clearLabels(); for (int i = 0; i <= 8; i++) { if (i > 4) { k = (float)4 / (8 - i); } else { k = (float)i / 4; } flow = Equations.calcFlow(inParams.kDefinition, inParams.fu, -inParams.fl, k); if (flow < 0 && inParams.runMode == RunModeType.DualMode) { vceff = inParams.injectPos * inParams.vc; } else { vceff = (1 - inParams.injectPos) * inParams.vc; } if (flow != 0) { if (float.IsInfinity(k)) { pos = Equations.calcInfPos(inParams.kDefinition, vceff, inParams.lf, inParams.uf, inParams.fu, inParams.fl); } else { pos = Equations.calcPos(inParams.kDefinition, vceff, inParams.lf, inParams.uf, flow, k); } if ((PhaseType)(phasei + 1) == PhaseType.Lower) { pos = -pos; } pos = inParams.convertUnit(pos, QuantityType.Time, inParams.natUnits, (PhaseType)(phasei + 1)); if (pos > 0 && !float.IsInfinity(pos)) { vx = minvx + pos / rangex * (maxvx - minvx); visAxis.addLabel(Util.toString(k, 2), vx, vy); } } } } } } // Y Axis range = rangey; if (!axes.logScale) { // normal scale yaxis.calcScale(range); rangey = yaxis.scale; miny = 0; maxy = rangey; } else { // log scale yaxis.majorStepSize = 1; yaxis.nMajorDivs = (int)rangey; yaxis.minorStepSize = 0; yaxis.nMinorDivs = 0; miny = maxcon - rangey; maxy = maxcon; } if (usePrefixes) { prefMassUnitsi = (int)inParams.massUnits; rangey0 = rangey; while (rangey0 >= 1000 && prefMassUnitsi < Enum.GetValues(typeof(MassUnitsType)).Length) { rangey0 /= 1000; multiplier /= 1000; prefMassUnitsi++; } while (rangey0 < 1 && prefMassUnitsi > 0) { rangey0 *= 1000; multiplier *= 1000; prefMassUnitsi--; } prefMassUnits = (MassUnitsType)prefMassUnitsi; label = inParams.getYaxisLegend(prefMassUnits); } else { label = inParams.getYaxisLegend(null); } if (dispDual) { vy = vrect.Top + 0.5f * vrect.Height; // positive y scale visAxes.addAxis("Upper Phase " + label, vrect.Left, vy, vrect.Left, vrect.Top, !previewMode, true, true, !previewMode, !axes.logScale, false, axes.logScale, !usePrefixes, multiplier, Colors.Black, 1, miny, maxy, yaxis.nMajorDivs, yaxis.majorStepSize, yaxis.nMinorDivs, yaxis.minorStepSize); // negative y scale if (!axes.logScale) { yaxis.inverse(); miny = -miny; maxy = -maxy; } visAxes.addAxis("Lower Phase " + label, vrect.Left, vy, vrect.Left, vrect.Bottom, !previewMode, true, true, !previewMode, false, false, axes.logScale, !usePrefixes, multiplier, Colors.Black, 1, miny, maxy, yaxis.nMajorDivs, yaxis.majorStepSize, yaxis.nMinorDivs, yaxis.minorStepSize); } else { visAxes.addAxis(label, vrect.Left, vrect.Bottom, vrect.Left, vrect.Top, !previewMode, true, true, !previewMode, true, false, axes.logScale, !usePrefixes, multiplier, Colors.Black, 1, miny, maxy, yaxis.nMajorDivs, yaxis.majorStepSize, yaxis.nMinorDivs, yaxis.minorStepSize); } // Raw Series (units) if (viewParams.showProbUnits) { for (s = 0; s < rawOutCells.Length; s++) { compRawOutCells = rawOutCells[s]; npoints = compRawOutCells.Length; c = s / nphases; visSerie = new VisSerie(); visSerie.type = VisSerieType.Units; visSerie.visRect = new Rect(rawvrect.X, rawvrect.Y, rawvrect.Width, rawvrect.Height); visSerie.compi = c; visSerie.drawSize = unitsize; visSerie.drawWeight = outSet.comps[c].m; visPoints = new List <VisPoint>(); if (viewParams.phaseDisplay == PhaseDisplayType.Lower) { phase = PhaseType.Lower; } else { phase = PhaseType.Upper; } if (nphases > 1) { phase = (PhaseType)((s % nphases) + 1); } if (phase == PhaseType.Upper) { rangex = axes.rangexu; } else { rangex = axes.rangexl; } if (c < ncomps) { visSerie.drawColor = Util.colorRange(c, ncomps); } else { visSerie.drawColor = Colors.Gray; } for (int i = 0; i < npoints; i++) { outCell = compRawOutCells[i]; vx = rawvrect.Left + outCell.pos / rangex * rawvrect.Width; if (s % nphases == 0) { vy = rawvrect.Top; } else { vy = rawvrect.Top + 0.5f * rawvrect.Height; } visPoints.Add(new VisPoint(vx, vy)); } visSerie.visPoints = visPoints.ToArray(); visRawSeries.Add(visSerie); } visOutSet.visRawSeries = visRawSeries.ToArray(); if (dispDual) { visAxis = new VisAxis(); visAxis.point1 = new VisPoint(rawvrect.Left, 0.5f * rawvrect.Height); visAxis.point2 = new VisPoint(rawvrect.Right, 0.5f * rawvrect.Height); visAxes.visAxes.Add(visAxis); } } visOutSet.visAxes = visAxes; // Series if (viewParams.yScale == YScaleType.Automatic) { maxcon = rangey; } for (s = 0; s < nseries; s++) { npoints = outSet.outCells[s].Length; c = s / nphases; visSerie = new VisSerie(); visSerie.type = VisSerieType.Graph; visSerie.visRect = new Rect(vrect.X, vrect.Y, vrect.Width, vrect.Height); visSerie.compi = c; visPoints = new List <VisPoint>(); if (nphases > 1) { phase = (PhaseType)((s % nphases) + 1); } else if (viewParams.phaseDisplay == PhaseDisplayType.Lower) { phase = PhaseType.Lower; } else { phase = PhaseType.Upper; } if (phase == PhaseType.Upper) { rangex = axes.rangexu; } else { rangex = axes.rangexl; } if (c < ncomps) { visSerie.drawWeight = outSet.comps[c].m; visSerie.multiColor = false; visSerie.drawColor = Util.colorRange(c, ncomps); sum = false; } else { visSerie.multiColor = true; visSerie.drawColor = Colors.Gray; sum = true; } if (viewParams.peaksDisplay != PeaksDisplayType.Sum || sum) { // Sum graph: multi color if (viewParams.yScale == YScaleType.Normalised) { maxcon = axes.maxcon[c]; } for (int i = 0; i < npoints; i++) { outCell = outSet.outCells[s][i]; vx = vrect.Left + outCell.pos / rangex * vrect.Width; if (viewParams.yScale == YScaleType.Logarithmic) { if (outCell.con != 0 && maxcon != 0) { con = (float)(1 + (Math.Log(Math.Abs(outCell.con)) - maxcon) / rangey); if (con < 0) { con = 0; } if (outCell.con < 0) { con = -con; } } else { con = 0; } } else { if (maxcon != 0) { con = outCell.con / maxcon; } } if (dispDual) { vy = vrect.Top + (1 - con) / 2 * vrect.Height; } else { vy = vrect.Bottom - con * vrect.Height; } if (c < ncomps) { visPoints.Add(new VisPoint(vx, vy)); } else { visPoints.Add(new VisPoint(vx, vy, outCell.color)); } } visSerie.visPoints = visPoints.ToArray(); visSeries.Add(visSerie); } } visOutSet.visSeries = visSeries.ToArray(); // Peaks for (int i = 0; i < outSet.comps.Count; i++) { outComp = outSet.comps[i]; if (outComp.phase == PhaseType.Upper) { vx = vrect.Left + outComp.drawPosition / axes.rangexu * vrect.Width; } else if (outComp.phase == PhaseType.Lower) { vx = vrect.Left + outComp.drawPosition / axes.rangexl * vrect.Width; } else { vx = vrect.Left + outComp.drawPosition / axes.rangex * vrect.Width; } if (dispDual && outComp.phase == PhaseType.Lower) { vy = vrect.Bottom; } else { vy = vrect.Top; } visComp = new VisComp(new VisPoint(vx, vy, Util.colorRange(i, ncomps, 0.5f)), outComp.label, Util.colorRange(i, ncomps, 2)); visOutSet.comps.Add(visComp); } visOutSet.posUnits = inParams.getXaxisUnits(); visOutSet.useMultiplier = usePrefixes; if (usePrefixes) { visOutSet.conMultiplier = multiplier; visOutSet.conUnits = inParams.getYaxisUnits(prefMassUnits); } else { visOutSet.conMultiplier = 1; visOutSet.conUnits = inParams.getYaxisUnits(null); } visOutSet.timeUnits = inParams.timeUnits.ToString(); return(visOutSet); }
private void transfer() { TransCon newcompconu; TransCon newcompconl; TransCon compconu; TransCon compconl; Comp comp; float cu, cl, cu0, cl0; float k; float dc, dcu, dcl; float tmu = inParams.Tmu * 60; // assume [min] => [s] float tml = inParams.Tml * 60; // assume [min] => [s] float tmnorm = inParams.Tmnorm * 60; // assume [min] => [s] float tm; bool inverseu, inversel; int offsetu, offsetl; int nsteps; int i, i0, j; float ka = inParams.ka; bool intPhaseSwitch = false; int deadvolstartsteps = (int)Math.Round(inParams.getVdeadStart()); int deadvolendsteps = (int)Math.Round(inParams.getVdeadEnd()); int deadvolinsertstartsteps = (int)Math.Round(inParams.getVdeadInjectStart()); int deadvolinsertendsteps = (int)Math.Round(inParams.getVdeadInjectEnd()); if (inParams.runMode == RunModeType.CoCurrent) { inverseu = false; inversel = false; offsetu = 0; offsetl = 0; } else { inverseu = false; inversel = true; offsetu = 0; offsetl = inParams.column2; } for (int compi = 0; compi < inParams.comps.Count; compi++) { compconu = conu[compi]; compconl = conl[compi]; comp = inParams.comps[compi]; if (fullmasstransfer) { nsteps = compconu.Count + compconl.Count - inParams.column2; if (inParams.runMode != RunModeType.CoCurrent) { offsetu = compconl.Count - inParams.column2; offsetl = compconl.Count; } } else { nsteps = inParams.column2; } // buffer for modified values newcompconu = new TransCon(compconu); newcompconl = new TransCon(compconl); k = comp.k; // phase movement (on buffered values) // mobile upper phase movement if (curPhase == PhaseType.Upper || curPhase == PhaseType.Both) { for (i = nsteps - 1; i >= 0; i--) { if (inParams.runMode == RunModeType.CoCurrent && i > inParams.column2) { tm = tmnorm; } else { tm = tmu; } cu = compconu.getNorm(i, offsetu, inverseu); cu0 = compconu.getNorm(i - 1, offsetu, inverseu); dcu = -tmnorm / tm * (cu - cu0) / dx; if (dcu != 0) { cu = newcompconu.getNorm(i, offsetu, inverseu); newcompconu.setNorm(i, offsetu, inverseu, cu + dcu * dt); } } } // mobile lower phase movement if (curPhase == PhaseType.Lower || curPhase == PhaseType.Both) { for (j = 0; j < nsteps; j++) { if (inParams.runMode == RunModeType.CoCurrent) { i = nsteps - 1 - j; // normal order: current OutCell - previous OutCell i0 = i - 1; } else { i = j; // inverse order: current OutCell - next OutCell i0 = i + 1; } if (inParams.runMode == RunModeType.CoCurrent && i > inParams.column2) { tm = tmnorm; } else { tm = tml; } cl = compconl.getNorm(i, offsetl, inversel); cl0 = compconl.getNorm(i0, offsetl, inversel); dcl = -tmnorm / tm * (cl - cl0) / dx; if (dcl != 0) { cl = newcompconl.getNorm(i, offsetl, inversel); newcompconl.setNorm(i, offsetl, inversel, cl + dcl * dt); } } } // copy back buffer: overwrite original values conu[compi] = newcompconu; conl[compi] = newcompconl; compconu = conu[compi]; compconl = conl[compi]; // do transfer between phases, over moved phases (on original values) // transfer between phases if (inParams.runMode != RunModeType.CoCurrent) { offsetu = 0; offsetl = inParams.column2; } for (i = 0; i < inParams.column2; i++) { // don't redistribute in dead volumes if (i >= deadvolstartsteps && i < deadvolendsteps && (i < deadvolinsertstartsteps || i >= deadvolinsertendsteps)) { // active cells cu = compconu.getNorm(i, offsetu, inverseu); cl = compconl.getNorm(i, offsetl, inversel); dc = Equations.calcDc(inParams.kDefinition, cu, cl, k); dcu = tmnorm * ka / inParams.uf * dc; dcl = -tmnorm * ka / inParams.lf * dc; if (dcu != 0) { compconu.setNorm(i, offsetu, inverseu, cu + dcu * dt); } if (dcl != 0) { compconl.setNorm(i, offsetl, inversel, cl + dcl * dt); } } } } if (curPhase == PhaseType.Upper || curPhase == PhaseType.Both || (inParams.runMode == RunModeType.Intermittent && inParams.viewUnits == QuantityType.Time)) { if (inParams.runMode == RunModeType.CoCurrent) { tm = tmnorm; } else { tm = tmu; } fdtxu += dtx * tmnorm / tm; while (fdtxu > 1) { for (int compi = 0; compi < inParams.comps.Count; compi++) { compconu = conu[compi]; if (curPhase == PhaseType.Upper || curPhase == PhaseType.Both) { if (fullmasstransfer) { compconu.Add(0); } else { compconu.insertAfterCol(compconu.getLastCol()); } } else { compconu.insertAfterCol(0); } } fdtxu -= 1; } } if (curPhase == PhaseType.Lower || curPhase == PhaseType.Both || (inParams.runMode == RunModeType.Intermittent && inParams.viewUnits == QuantityType.Time)) { if (inParams.runMode == RunModeType.CoCurrent) { tm = tmnorm; } else { tm = tml; } fdtxl += dtx * tmnorm / tm; while (fdtxl > 1) { for (int compi = 0; compi < inParams.comps.Count; compi++) { compconl = conl[compi]; if (curPhase == PhaseType.Lower || curPhase == PhaseType.Both) { if (fullmasstransfer) { compconl.Add(0); } else { compconl.insertAfterCol(compconl.getLastCol()); } } else { compconl.insertAfterCol(0); } } fdtxl -= 1; } } if (inParams.runMode == RunModeType.Intermittent) { if (inParams.intMode != IntModeType.Component) { if (curPhase == PhaseType.Upper) { intamountu -= dtreal; if (intamountu <= 0) { intPhaseSwitch = true; } } if (curPhase == PhaseType.Lower) { intamountl -= dtreal; if (intamountl <= 0) { intPhaseSwitch = true; } } } if (intPhaseSwitch && intit / 2 < inParams.intMaxIt) { if (curPhase == PhaseType.Upper) { curPhase = PhaseType.Lower; } else { curPhase = PhaseType.Upper; } intit++; newIntAmount(); } } runcols += (1.0f / timesteps); }
private void inject() { Comp comp; float feedtime = 0; float compm; float fu; float fl; int insposu; int insposl; float tmnorm = inParams.Tmnorm; bool first = (it == 0); insposu = (int)inParams.getInjectPosNorm(); if (inParams.runMode == RunModeType.CoCurrent) { insposl = insposu; } else { insposl = inParams.column2 - 1 - insposu; } if (inParams.injectMode == InjectModeType.Instant) { if (!first) { return; } } else { feedtime = inParams.convertUnit(inParams.injectFeed, inParams.injectFeedUnits, QuantityType.Time, inParams.injectPhase); } for (int compi = 0; compi < inParams.comps.Count; compi++) { comp = inParams.comps[compi]; if (inParams.injectMode == InjectModeType.Instant) { compm = comp.m; } else if (inParams.injectMode == InjectModeType.Continuous) { compm = comp.concentration; } else { compm = comp.m / feedtime * dtreal; if (compm > compTotMass[compi]) { compm = compTotMass[compi]; } } if (compTotMass[compi] > 0 || inParams.injectMode == InjectModeType.Continuous) { if (inParams.injectPhase == PhaseType.Upper) { conu[compi][insposu] += compm; } else if (inParams.injectPhase == PhaseType.Lower) { conl[compi][insposl] += compm; } else { // make sure to have 'perfect' distribution if sample is inserted in both phases fu = Equations.calcTransferU(inParams.kDefinition, comp.k * inParams.px); fl = Equations.calcTransferL(inParams.kDefinition, comp.k * inParams.px); conu[compi][insposu] += fu * compm; conl[compi][insposl] += fl * compm; } compTotMass[compi] -= compm; } } }
private List <OutComp> storePeaks(List <TransCon> conu0, List <TransCon> conl0, int offsetu0, int offsetl0, bool[] inversePhase, Axes axes, ViewParams viewparams, bool showCol) { List <OutComp> outComps = new List <OutComp>(); OutComp outComp; TransCon compconu; TransCon compconl; int ncomps = inParams.comps.Count; float cu, cl; float con, maxcon; float pos, normpos, realpos; float width, hwidth, swidth; float sumavg, avg; float normavg, realavg; float totm, totmup, totmlp; bool up; int nsteps; int offsetu = 0; int offsetl = 0; bool inverseu, inversel; float contarget, conother, conall; float purity; float recovery; if (inParams.runMode == RunModeType.CoCurrent) { inverseu = false; inversel = false; offsetu = 0; offsetl = 0; } else { inverseu = false; inversel = true; } for (int compi = 0; compi < ncomps; compi++) { compconu = conu0[compi]; compconl = conl0[compi]; nsteps = compconu.Count + compconl.Count - inParams.column2; if (inParams.runMode != RunModeType.CoCurrent) { offsetu = compconl.Count - inParams.column2; offsetl = compconl.Count; } pos = 0; maxcon = 0; normpos = 0; up = false; for (int i = 0; i < nsteps; i++) { cu = compconu.getNormCon(i, offsetu, inverseu); cl = compconl.getNormCon(i, offsetl, inversel); con = cu + cl; if (con > maxcon) { maxcon = con; normpos = i; up = (cu > cl); } } hwidth = calcHeightWidth(compconu, compconl, offsetu, offsetl, inverseu, inversel, nsteps, normpos, maxcon); swidth = calcSlopeWidth(compconu, compconl, offsetu, offsetl, inverseu, inversel, nsteps, normpos); width = Equations.calcBestWidth(hwidth, swidth); // totm + avg totm = 0; totmup = 0; totmlp = 0; sumavg = 0; for (int i = 0; i < nsteps; i++) { cu = compconu.getNorm(i, offsetu, inverseu); cl = compconl.getNorm(i, offsetl, inversel); //if (inParams->runMode == RunMode::Co && i >= inParams->column2) { // correct cu, cl ? //} con = cu + cl; sumavg += (i * con); totm += con; totmup += cu; totmlp += cl; } normavg = sumavg / totm; // purity contarget = 0; conall = 0; for (int i = 0; i < nsteps; i++) { cu = compconu.getNorm(i, offsetu, inverseu); cl = compconl.getNorm(i, offsetl, inversel); con = cu + cl; if (con > mincon) { // target component present contarget += con; for (int c = 0; c < ncomps; c++) { cu = conu0[c].getNorm(i, offsetu, inverseu); cl = conl0[c].getNorm(i, offsetl, inversel); con = cu + cl; conall += con; } } } purity = contarget / conall; // recovery contarget = 0; for (int i = 0; i < nsteps; i++) { conother = 0; for (int c = 0; c < ncomps; c++) { if (c != compi) { cu = conu0[c].getNorm(i, offsetu, inverseu); cl = conl0[c].getNorm(i, offsetl, inversel); con = cu + cl; conother += con; } } if (conother < mincon) { cu = compconu.getNorm(i, offsetu, inverseu); cl = compconl.getNorm(i, offsetl, inversel); con = cu + cl; contarget += con; } } recovery = contarget; outComp = new OutComp(inParams.comps[compi]); outComp.height = maxcon; outComp.totm = totm; outComp.totmup = totmup; outComp.totmlp = totmlp; outComp.purity = purity; outComp.recovery = recovery; if (up) { outComp.phase = PhaseType.Upper; // convert norm back to model pos = compconu.convNormToModel((int)normpos, offsetu, inverseu); avg = compconu.convNormToModel((int)normavg, offsetu, inverseu); // convert normal position back into screen position (using out/draw params): outComp.drawPosition = compconu.convModelToNorm((int)pos, offsetu0, inversePhase[0]); // convert position to retention realpos = compconu.Count - pos; realavg = compconu.Count - avg; } else { outComp.phase = PhaseType.Lower; // convert norm back to model pos = compconl.convNormToModel((int)normpos, offsetl, inversel); avg = compconl.convNormToModel((int)normavg, offsetl, inversel); // convert normal position back into screen position (using out/draw params): outComp.drawPosition = compconl.convModelToNorm((int)pos, offsetl0, inversePhase[1]); // convert position to retention realpos = compconl.Count - pos; realavg = compconl.Count - avg; } outComp.outCol = (pos > inParams.column2); outComp.eluted = outComp.outCol; if (!outComp.eluted) { // if not eluted; redo position calc depending on point of insertion outComp.phase = PhaseType.None; // if (inParams->runMode != RunMode::Lp) { pos = compconu.convNormToModel((int)normpos, offsetu, inverseu); avg = compconu.convNormToModel((int)normavg, offsetu, inverseu); // } else { // pos = compconl.convNormToModel((int)normpos,offsetl,inversel); // avg = compconl.convNormToModel((int)normavg,offsetl,inversel); // } } if (outComp.eluted) { outComp.retention = inParams.convertUnit(realpos, inParams.natUnits, viewparams.viewUnits, outComp.phase); outComp.average = inParams.convertUnit(realavg, inParams.natUnits, viewparams.viewUnits, outComp.phase); outComp.width = inParams.convertUnit(width, inParams.natUnits, viewparams.viewUnits, outComp.phase); outComp.hwidth = inParams.convertUnit(hwidth, inParams.natUnits, viewparams.viewUnits, outComp.phase); outComp.swidth = inParams.convertUnit(swidth, inParams.natUnits, viewparams.viewUnits, outComp.phase); } else { // if not outcol: overwrite with column value outComp.retention = inParams.convertColUnit(pos, inParams.natUnits, viewparams.viewUnits); outComp.average = inParams.convertColUnit(avg, inParams.natUnits, viewparams.viewUnits); outComp.width = inParams.convertColUnit(width, inParams.natUnits, viewparams.viewUnits); outComp.hwidth = inParams.convertColUnit(hwidth, inParams.natUnits, viewparams.viewUnits); outComp.swidth = inParams.convertColUnit(swidth, inParams.natUnits, viewparams.viewUnits); outComp.phase = PhaseType.None; } outComp.sigma = outComp.width / 4; outComps.Add(outComp); } return(outComps); }
public float convertColUnit(float val0, QuantityType srcUnits, QuantityType dstUnits) { float val = val0; float tm = 0; float flow = 0; if (dstUnits == srcUnits) { return(val); } flow = fu + fl; tm = vc / flow; if (model == ModelType.Transport) { if (srcUnits == QuantityType.Steps && dstUnits == QuantityType.Volume) { val *= (vc / column); return(val); } else if (srcUnits == QuantityType.Volume && dstUnits == QuantityType.Steps) { val *= (column / vc); return(val); } // x -> time switch (srcUnits) { case QuantityType.Steps: val *= (tm / column); break; case QuantityType.Volume: val /= flow; break; } // time -> y switch (dstUnits) { case QuantityType.Steps: val /= (tm / column); break; case QuantityType.Volume: val *= flow; break; case QuantityType.Column: val /= tm; break; case QuantityType.ReS: val = Equations.calcK(kDefinition, vu, vl, fu, fl, val * flow); break; } } else { // x -> vol switch (srcUnits) { case QuantityType.Steps: val *= (vc / column); break; case QuantityType.Time: val *= flow; break; } // vol -> y switch (dstUnits) { case QuantityType.Steps: val /= (vc / column); break; case QuantityType.Time: val /= flow; break; case QuantityType.Column: val /= vc; break; case QuantityType.ReS: val = Equations.calcK(kDefinition, vu, vl, fu, fl, val); break; } } return(val); }
public float convertUnit(float val0, QuantityType srcUnits, QuantityType dstUnits, PhaseType phase) { float val = val0; float vm0 = 0; float vm = 0; float tm = 0; float flow = 0; if (dstUnits == srcUnits) { return(val); } if (phase == PhaseType.Upper || phase == PhaseType.Both || runMode == RunModeType.CoCurrent) { vm0 += vu; vm += vu * fnormu; flow += fu; if (fu != 0) { tm += vu / fu; } } if (phase == PhaseType.Lower || phase == PhaseType.Both || runMode == RunModeType.CoCurrent) { vm0 += vl; vm += vl * fnorml; flow += fl; if (fl != 0) { tm += vl / fl; } } if (model == ModelType.Transport) { if (runMode == RunModeType.CoCurrent) { tm = Tmnorm; } // x -> time switch (srcUnits) { case QuantityType.Steps: val *= (tm / column); break; case QuantityType.Volume: val /= flow; break; } tm = Tmnorm; // time -> y switch (dstUnits) { case QuantityType.Steps: val /= (tm / column); break; case QuantityType.Volume: val *= flow; break; case QuantityType.Column: val /= tm; break; case QuantityType.ReS: val = Equations.calcK(kDefinition, vu, vl, fu, fl, val * flow); break; } } else { // x -> vol switch (srcUnits) { case QuantityType.Steps: val *= (vm / column); break; case QuantityType.Time: val *= flow; break; } // vol -> y switch (dstUnits) { case QuantityType.Steps: val /= (vm / column); break; case QuantityType.Time: val /= flow; break; case QuantityType.Column: val /= vm0; break; case QuantityType.ReS: val = Equations.calcK(kDefinition, vu, vl, fu, fl, val); break; } } return(val); }
public OutComp calcNewPos(Comp comp, float fu, float fl, float vc, float pos0, QuantityType natUnits, bool limit, float maxpos, QuantityType limitUnits) { OutComp outcomp = new OutComp(); float flow; float ret; float rettime; float vceff; PhaseType phase = new PhaseType(); float elutable; float lf = inParams.lf; float uf = inParams.uf; float px = inParams.px; KdefType kdef = inParams.kDefinition; float k = comp.k; // * flow if (natUnits == QuantityType.Steps) { flow = Equations.calcStepFlow(kdef, lf, uf, fu, fl, k); } else { flow = Equations.calcFlow(kdef, fu, fl, k); } if (inParams.runMode != RunModeType.CoCurrent) { elutable = Equations.calcElutable(kdef, fu, -fl, k); } else { elutable = Equations.calcElutable(kdef, fu, fl, k); } if (elutable > 0.01) { // will elute // * vceff if (flow < 0) { vceff = pos0; } else { vceff = vc - pos0; } // * ret // [time] rettime = Equations.calcPos(kdef, vceff, lf, uf, flow, k); outcomp.retentionTime = rettime; if (rettime < 0) { phase = PhaseType.Lower; } else { phase = PhaseType.Upper; } if (natUnits == QuantityType.Steps) { // [steps] ret = rettime; } else { // [volume] or [time] ret = inParams.convertUnit(rettime, QuantityType.Time, natUnits, phase); } outcomp.retention0 = ret; // * new pos if (limit && (Math.Abs(rettime) > maxpos && limitUnits == QuantityType.Time || Math.Abs(ret) > maxpos && limitUnits != QuantityType.Time)) { // [volume] or [steps] outcomp.retention = pos0 + Equations.calcColPos(kdef, maxpos, lf, uf, flow, k); outcomp.eluted = false; } else { outcomp.retention = ret; outcomp.eluted = true; } } else { outcomp.retention = pos0; if (flow < 0) { phase = PhaseType.Lower; } else { phase = PhaseType.Upper; } } outcomp.phase = phase; return(outcomp); }
public OutSet storeOutVar(ViewParams viewParams) { // use predictive equations OutSet outSet = new OutSet(inParams); OutCell[][] outCells; Axes axes; Comp comp; OutComp outComp; OutComp outCompt = null; float pos, pos0, post; float totposu, totposl; float timepos; float maxtime0; float eepos = 0; float intAmount = 0; float sigma, sigma0; float timesigma = 0; float con, maxcon; float amp0; float div0; float maxposu = 0; float maxposl = 0; float mindrawpos = 0; float maxdrawpos = 0; float range; float stepsize; int ncomps = inParams.comps.Count; int nsize = 1000; float k; PhaseType phase = new PhaseType(); KdefType kdef = inParams.kDefinition; RunModeType runMode = inParams.runMode; QuantityType natUnits = inParams.natUnits; float injectPos = 0; float lf = inParams.lf; float uf = inParams.uf; float px = inParams.px; float fu = 0; float fl = 0; float fnormu = 0; float fnorml = 0; float vc = 0; float mixspeed = 0; float efficiency = 0; bool allincol = true; bool timeMode = (inParams.viewUnits == QuantityType.Time); bool eeMode = (inParams.eeMode != EEModeType.None); bool intMode = (inParams.runMode == RunModeType.Intermittent); bool intCompMode = (inParams.intMode == IntModeType.Component); int intit; bool eluted; float elutable; eeDone = false; if (inParams.model == ModelType.CCD) { // [steps] vc = inParams.column; injectPos = inParams.getInjectPosNorm(); if (runMode == RunModeType.CoCurrent) { injectPos = (inParams.column - 1) - injectPos; } fnormu = inParams.fnormu; fnorml = inParams.fnorml; // always use normalised flows fu = fnormu; fl = fnorml; mixspeed = 1; efficiency = Equations.calcEff1(inParams.efficiency); } else if (inParams.model == ModelType.Probabilistic) { // [volume] vc = inParams.vc; injectPos = inParams.getInjectPosNorm(); fu = inParams.fu; fl = inParams.fl; // normalise flow fnormu = inParams.fnormu; fnorml = inParams.fnorml; if (fnorml > fnormu) { fnormu /= fnorml; fnorml = 1; } else { fnorml /= fnormu; fnormu = 1; } mixspeed = inParams.mixSpeed; efficiency = Equations.calcEff1(inParams.efficiency); } else if (inParams.model == ModelType.Transport) { // [time] natUnits = QuantityType.Time; vc = inParams.vc; injectPos = inParams.getInjectPosNorm(); fu = inParams.fu; fl = inParams.fl; // normalise flow fnormu = fu / uf; fnorml = fl / lf; if (fnorml > fnormu) { fnormu /= fnorml; fnorml = 1; } else { fnorml /= fnormu; fnormu = 1; } mixspeed = 1; efficiency = (float)Math.Sqrt(inParams.ka * 10); // **** make correct for f? dx? dt? } if (runMode != RunModeType.CoCurrent) { fl = -fl; fnorml = -fnorml; } // Set maxpos for (int compi = 0; compi < ncomps; compi++) { comp = inParams.comps[compi]; outComp = outSet.comps[compi]; elutable = Equations.calcElutable(kdef, fu, fl, outComp.k); outComp.willElute = (elutable > 0.01); if (outComp.willElute) { outCompt = calcNewPos(comp, fu, fl, vc, injectPos, natUnits); // outcomp is reassigned outComp = outSet.comps[compi]; // overwrite comp outComp.willElute = true; // restore willElute if (comp.elute) { if (outCompt.retention < 0) { phase = PhaseType.Lower; if (Math.Abs(outCompt.retention) > maxposl) { maxposl = Math.Abs(outCompt.retention); } } else { phase = PhaseType.Upper; if (Math.Abs(outCompt.retention) > maxposu) { maxposu = Math.Abs(outCompt.retention); } } sigma = Equations.calcSigma(kdef, fnormu, fnorml, comp.k * px, outCompt.retentionTime, mixspeed, efficiency); if (runMode == RunModeType.DualMode && inParams.model != ModelType.Transport) { sigma *= 2; } sigma = inParams.convertUnit(sigma, QuantityType.Time, natUnits, phase); } } else { if (intMode && inParams.intFinalElute) { outComp.willElute = true; } } } if (intMode && !intCompMode) { intamountu = inParams.convertUnit(inParams.intUpSwitch, (QuantityType)inParams.intMode, natUnits, PhaseType.Upper); intamountl = inParams.convertUnit(inParams.intLpSwitch, (QuantityType)inParams.intMode, natUnits, PhaseType.Lower); if (inParams.model == ModelType.CCD) { intamountut = intamountu; } else { intamountut = inParams.convertUnit(inParams.intUpSwitch, (QuantityType)inParams.intMode, QuantityType.Time, PhaseType.Upper); } if (inParams.model == ModelType.CCD) { intamountlt = intamountl; } else { intamountlt = inParams.convertUnit(inParams.intLpSwitch, (QuantityType)inParams.intMode, QuantityType.Time, PhaseType.Lower); } } if (inParams.model == ModelType.CCD) { pos0 = vc / inParams.uf * inParams.maxIt; // in reality [steps] } else { pos0 = vc * inParams.maxIt; } if (inParams.doMaxIt && maxposu > pos0) { maxposu = pos0; } if (inParams.model == ModelType.CCD) { pos0 = vc / inParams.lf * inParams.maxIt; // in reality [steps] } else { pos0 = vc * inParams.maxIt; } if (inParams.doMaxIt && maxposl > pos0) { maxposl = pos0; } // init estmax [time/steps] previewParams.estmaxtime = 0; previewParams.estmaxstep = 0; // Set peaks // *** improve int mode: loop for [intit] with inner loop for [comps]: enable compmode and time scale correction for (int i = 0; i < ncomps; i++) { comp = inParams.comps[i]; outComp = outSet.comps[i]; k = comp.k; post = 0; // Calculate pos if (intMode) { // Int mode intit = 0; eluted = false; totposu = 0; totposl = 0; timepos = 0; pos = injectPos; phase = inParams.intStartPhase; while (intit / 2 < inParams.intMaxIt && !eluted) { if (phase == PhaseType.Upper) { if (!intCompMode) { if (natUnits == QuantityType.Steps) { intAmount = intamountu; } else { intAmount = intamountut; } } outCompt = calcNewPos(comp, fu, 0, vc, pos, natUnits, !intCompMode, intAmount, QuantityType.Time); } else { if (!intCompMode) { if (natUnits == QuantityType.Steps) { intAmount = intamountl; } else { intAmount = intamountlt; } } outCompt = calcNewPos(comp, 0, fl, vc, pos, natUnits, !intCompMode, intAmount, QuantityType.Time); } eluted = outCompt.eluted; if (!eluted) { post += Math.Abs(outCompt.retention - pos); pos = outCompt.retention; if (phase == PhaseType.Upper) { totposu += intamountu; timepos += intamountut; } else { totposl += intamountl; timepos += intamountlt; } // prepare for next iteration/phase if (phase == PhaseType.Upper) { phase = PhaseType.Lower; } else { phase = PhaseType.Upper; } intit++; } } if (inParams.intFinalElute && !eluted) { // elute if (phase == PhaseType.Upper) { outCompt = calcNewPos(comp, fu, 0, vc, pos, natUnits); } else { outCompt = calcNewPos(comp, fl, 0, vc, pos, natUnits); } eluted = outCompt.eluted; } if (eluted) { // timepos is always positive //timepos+= inparams.convertUnit(Math::Abs(outCompt.ret),natUnits,UnitsType.Time,phase); timepos += Math.Abs(outCompt.retentionTime); if (timeMode) { // use timepos to calc pos if (inParams.model == ModelType.CCD) { pos = timepos; } else { pos = inParams.convertUnit(timepos, QuantityType.Time, natUnits, phase); } // correct negative pos if (phase == PhaseType.Lower) { pos = -Math.Abs(pos); } } else if (phase == PhaseType.Upper) { pos = totposu + outCompt.retention0; } else { pos = -totposl + outCompt.retention0; } } outComp.intIt = (float)intit / 2; outComp.intItSet = true; } else { // Normal (not Int) mode outCompt = calcNewPos(comp, fu, fl, vc, injectPos, natUnits, true, Math.Max(maxposu, maxposl), QuantityType.Volume); pos = outCompt.retention; post += Math.Abs(pos - injectPos); timepos = Math.Abs(outCompt.retentionTime); eluted = outCompt.eluted; } outComp.eluted = eluted; outComp.outCol = eluted; pos0 = pos; if (!eluted && eeMode) { // EE mode eeDone = true; if (inParams.isPosEEdir()) { eepos = inParams.convertUnit(maxposu, natUnits, inParams.viewUnits, phase); if (!timeMode) { eepos += (vc - pos0); } else { eepos = 0; } pos = maxposu + (vc - pos0); outCompt.phase = PhaseType.Upper; } else { eepos = inParams.convertUnit(maxposl, natUnits, inParams.viewUnits, phase); if (!timeMode) { eepos += pos0; } else { eepos = 0; } pos = -maxposl - pos0; outCompt.phase = PhaseType.Lower; } outComp.outCol = true; } phase = outCompt.phase; // Calculate sigma if (outComp.outCol || outComp.willElute) { // include ee outcol timesigma = Equations.calcSigma(kdef, fnormu, fnorml, k * px, Math.Abs(timepos), mixspeed, efficiency); if (runMode == RunModeType.DualMode) { timesigma *= 2; } if (natUnits == QuantityType.Steps) { // [steps] sigma = timesigma; } else { // [volume] if (!outComp.eluted) { sigma = inParams.convertColUnit(timesigma, QuantityType.Time, natUnits); } else { sigma = inParams.convertUnit(timesigma, QuantityType.Time, natUnits, phase); } } if (!outComp.eluted) { // calc col sigma also for EE outcol // [volume] or [steps] sigma0 = sigma; sigma = Equations.calcColSigma(sigma0, outCompt.retention0, post, vc); } if (outComp.eluted) { if (phase == PhaseType.Lower) { pos0 = pos - 3 * sigma; if (pos0 < mindrawpos) { mindrawpos = pos0; } } else { pos0 = pos + 3 * sigma; if (pos0 > maxdrawpos) { maxdrawpos = pos0; } } } } else { sigma = 1; phase = PhaseType.None; } outComp.sigma = sigma; outComp.phase = phase; // set estmax [time] if (outComp.outCol) { maxtime0 = Math.Abs(timepos) + 3 * timesigma; if (maxtime0 > previewParams.estmaxtime) { previewParams.estmaxtime = maxtime0; } } if (outComp.outCol) { if (outComp.eluted) { outComp.retention = inParams.convertUnit(Math.Abs(pos), natUnits, viewParams.viewUnits, phase); outComp.width = inParams.convertUnit(4 * sigma, natUnits, viewParams.viewUnits, phase); } else { // not eluted but outcol (by EE) outComp.retention = eepos; outComp.width = 4 * sigma; } } else { outComp.retention = inParams.convertColUnit(Math.Abs(pos), natUnits, viewParams.viewUnits); outComp.width = inParams.convertColUnit(4 * sigma, natUnits, viewParams.viewUnits); } outComp.drawPosition = pos; // convert to real value later // Calculate height if (float.IsInfinity(k) || sigma == 0) { outComp.height = 1; } else { outComp.height = Equations.calcHeight(sigma); // [volume] } outComp.height *= comp.m; } // set estmax [steps] if (inParams.doMaxIt) { // overwrite if maxit is set pos0 = 0; if (fu != 0) { pos0 = inParams.convertUnit(inParams.maxIt * vc, QuantityType.Volume, QuantityType.Time, PhaseType.Upper); } if (fl != 0) { pos0 = Math.Max(pos0, inParams.convertUnit(inParams.maxIt * vc, QuantityType.Volume, QuantityType.Time, PhaseType.Lower)); } if (previewParams.estmaxtime > pos0) { previewParams.estmaxtime = pos0; } } if (previewParams.estmaxtime == 0) { previewParams.estmaxtime = inParams.Tmnorm; previewParams.estmaxstep = inParams.column; } else { if (natUnits == QuantityType.Steps) { // CCD mode: time units are actually step units previewParams.estmaxstep = previewParams.estmaxtime; } else { previewParams.estmaxstep = inParams.convertUnit(previewParams.estmaxtime, QuantityType.Time, QuantityType.Steps, phase); } } if (maxdrawpos == 0 && mindrawpos == 0) { if (inParams.doMaxIt) { maxdrawpos = maxposu; mindrawpos = -maxposl; } } if (eeMode) { if (inParams.isPosEEdir()) { maxdrawpos += vc; } else { mindrawpos -= vc; } } range = maxdrawpos - mindrawpos + vc; // Correct drawpos for (int i = 0; i < ncomps; i++) { outComp = outSet.comps[i]; pos0 = outComp.drawPosition; if (outComp.outCol) { if (outComp.phase == PhaseType.Upper) { pos0 = maxdrawpos - pos0 + vc; } else { pos0 = mindrawpos - pos0; } allincol = false; } outComp.drawPosition = convModelToReal(pos0, mindrawpos); } // Set Axes axes = outSet.axes; axes.rangex = range; //inparams->convertUnit(drawrange,UnitsType::Time,viewparams->viewUnits,PhaseType::Up); axes.showCol = true; axes.colstart = convModelToReal(0, mindrawpos); axes.colend = convModelToReal(vc, mindrawpos); axes.scaleminulabel = 0; axes.scalemaxulabel = inParams.convertUnit(maxdrawpos, natUnits, inParams.natUnits, PhaseType.Upper); axes.scaleminllabel = 0; axes.scalemaxllabel = inParams.convertUnit(-mindrawpos, natUnits, inParams.natUnits, PhaseType.Lower); axes.scaleminu = convModelToReal(maxdrawpos + vc, mindrawpos); axes.scalemaxu = convModelToReal(vc, mindrawpos); axes.scaleminl = convModelToReal(mindrawpos, mindrawpos); axes.scalemaxl = convModelToReal(0, mindrawpos); axes.logScale = (viewParams.yScale == YScaleType.Logarithmic); axes.update(); // init outcells outCells = new OutCell[ncomps][]; for (int compi = 0; compi < ncomps; compi++) { outCells[compi] = new OutCell[nsize]; } axes.maxcon = new List <float>(ncomps); // Store outcells for (int compi = 0; compi < ncomps; compi++) { comp = inParams.comps[compi]; outComp = outSet.comps[compi]; // Pre-calcs to improve performance pos0 = outComp.drawPosition; sigma = outComp.sigma; if (sigma == 0) { sigma = 1; } amp0 = comp.m * Equations.calcHeight(sigma); div0 = 2 * (float)Math.Pow(sigma, 2); stepsize = range / nsize; maxcon = 0; for (int i = 0; i < nsize; i++) { pos = i * stepsize; // Real position // make sure peak top gets drawn: if (Math.Abs(pos - pos0) <= stepsize) { con = amp0; } else { con = amp0 * (float)Math.Exp(-Math.Pow(pos - pos0, 2) / div0); } if (con > maxcon && (outComp.outCol || allincol)) { maxcon = con; } outCells[compi][i] = new OutCell(pos, con); } axes.maxcon.Add(maxcon); // Correct sigma: outComp.sigma = outComp.width / 4; } outSet.outCells = outCells; return(outSet); }