Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function powerlossesF(curveIt: Point[], curveIV: Point[]): number {
- let powerAverage: number = 0;
- const tMax: number = curveIt[curveIt.length - 1].x;
- const tRange: number[] = Interpolation.linearSpace_(0, tMax, PLDiodeFormula.POINT_FOR_INTEGRAL);
- const tStep: number = tRange[1] - tRange[0];
- let IdPrec: number = 0;
- for (let i: number = 0; i < tRange.length; i++) {
- let Id: Point = Interpolation.stdlinearY(tRange[i], curveIt)
- let Vr: Point;
- if (Id != null && !isNaN(Id.y)) {
- if (IdPrec != Id.y) {
- Vr = Interpolation.cubicX(Id.y, curveIV);
- }
- if (Vr != null && Id.y != 0) {
- powerAverage += Id.y * Vr.x * tStep;
- }
- IdPrec = Id.y;
- }
- }
- return powerAverage / tMax;
- }
- export function powerlossesR(curveVt: Point[], curveIV: Point[]): number {
- let powerAverage: number = 0;
- const tMax: number = curveVt[curveVt.length - 1].x;
- const tRange: number[] = Interpolation.linearSpace_(0, tMax, PLDiodeFormula.POINT_FOR_INTEGRAL);
- const tStep: number = tRange[1] - tRange[0];
- let VrPrec: number = 0;
- for (let i: number = 0; i < tRange.length; i++) {
- let Vr: Point = Interpolation.stdlinearY(tRange[i], curveVt)
- if (Vr != null && !isNaN(Vr.y)) {
- let Id: Point;
- if (VrPrec != Vr.y) {
- Id = Interpolation.cubicY(Vr.y, curveIV);
- }
- if (Id != null && Vr.y != 0) {
- powerAverage += Id.y * Vr.y * tStep;
- }
- VrPrec = Vr.y;
- }
- }
- return powerAverage / tMax;
- }
- export function curveAt(t: number, curves: PlotInfo_VO[], factory: Function): Point[] {
- const cLength: number = curves.length;
- if (cLength == 0) {
- return []
- }
- if (cLength == 1)
- return curves[0].data;
- if (t <= curves[1].temperature) {
- return factory(t, curves[0], curves[1]);
- }
- if (t > curves[cLength - 1].temperature) {
- return factory(t, curves[cLength - 2], curves[cLength - 1]);
- }
- for (let i:number = 1; i < (cLength - 1); i++) {
- if (curves[i].temperature < t && t <= curves[i + 1].temperature) {
- return factory(t, curves[i], curves[i + 1]);
- }
- }
- return factory(t, curves[cLength - 2], curves[cLength - 1]);
- }
- export function forward(t: number, a: PlotInfo_VO, b: PlotInfo_VO): Point[] {
- if (t == a.temperature)
- return a.data;
- if (t == b.temperature)
- return b.data;
- let curve: Point[] = [];
- a.data.forEach((item) => {
- let indexOfItem: number = a.data.indexOf(item);
- if (indexOfItem != -1) {
- const pa: Point = new Point(a.temperature, a.data[indexOfItem].x);
- const pb: Point = new Point(b.temperature, a.data[indexOfItem].x);
- curve.push(new Point(Interpolation.linearY_(t, pa, pb), item.y));
- }
- });
- return curve;
- }
- export function reverse(t: number, a: PlotInfo_VO, b: PlotInfo_VO): Point[] {
- if (t == a.temperature)
- return a.data;
- if (t == b.temperature)
- return b.data;
- let curve: Point[] = [];
- a.data.forEach((item) => {
- let indexOfItem: number = a.data.indexOf(item);
- if (indexOfItem != -1) {
- const pa: Point = new Point(a.temperature, a.data[indexOfItem].y);
- const pb: Point = new Point(b.temperature, a.data[indexOfItem].y);
- curve.push(new Point(item.x, Interpolation.exponentialY_(t, pa, pb)));
- }
- });
- return curve;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement