Skip to content
Snippets Groups Projects
Commit dbb110e0 authored by David Dorchies's avatar David Dorchies
Browse files

#35 Debug inclined apron discretisation

parent 61ab6372
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ import { MacrorugoCompound } from "../../src/macrorugo/macrorugo_compound"; ...@@ -4,7 +4,7 @@ import { MacrorugoCompound } from "../../src/macrorugo/macrorugo_compound";
import { Props } from "../../src/props"; import { Props } from "../../src/props";
import { Session } from "../../src/session"; import { Session } from "../../src/session";
let B: number; let BR: number;
describe("MacroRugoCompound", () => { describe("MacroRugoCompound", () => {
describe("Default 1 apron", () => { describe("Default 1 apron", () => {
...@@ -20,22 +20,32 @@ describe("MacroRugoCompound", () => { ...@@ -20,22 +20,32 @@ describe("MacroRugoCompound", () => {
}); });
describe("Default inclined but flat apron", () => { describe("Default inclined but flat apron", () => {
beforeAll(() => { beforeAll(() => {
B = 2; BR = 0;
}); });
beforeEach(() => { beforeEach(() => {
B++; BR += 1;
}); });
for (let i = 2; i < 6; i++) { for (let i = 1; i < 10; i += 1) {
it(`B = ${i} should return same result as Macrorugo`, () => { it(`B = ${i} should return same result as Macrorugo`, () => {
const mrc = Session.getInstance().createNub( const mrc = Session.getInstance().createNub(
new Props({ calcType: CalculatorType.MacroRugoCompound }) new Props({ calcType: CalculatorType.MacroRugoCompound })
) as MacrorugoCompound; ) as MacrorugoCompound;
mrc.properties.setPropValue("InclinedApron", true); mrc.properties.setPropValue("InclinedApron", true);
mrc.prms.B.singleValue = 4; mrc.prms.BR.singleValue = BR;
const mr = Session.getInstance() const mr = Session.getInstance()
.createNub(new Props({ calcType: CalculatorType.MacroRugo })) as MacroRugo; .createNub(new Props({ calcType: CalculatorType.MacroRugo })) as MacroRugo;
mr.prms.Q.setCalculated(); mr.prms.Q.setCalculated();
expect(mrc.CalcSerie().vCalc).toBeCloseTo(mr.CalcSerie().vCalc * mrc.prms.B.currentValue, 3); expect(mrc.CalcSerie().vCalc)
.toBeCloseTo(mr.CalcSerie().vCalc * mrc.prms.BR.currentValue / mr.prms.B.currentValue, 3);
const ax = mrc.prms.PBD.v / Math.sqrt(mrc.prms.C.v);
let B: number = 0;
for (const child of mrc.children) {
expect(child.result.values.xCenter)
.toBeCloseTo(B + child.prms.B.v / 2);
B += child.prms.B.v;
expect(child.prms.B.v).toBeGreaterThanOrEqual(ax / 4);
}
expect(B).toBeCloseTo(mrc.prms.BR.currentValue, 6);
}); });
} }
}); });
......
...@@ -39,9 +39,12 @@ export class MacrorugoCompound extends MacroRugo { ...@@ -39,9 +39,12 @@ export class MacrorugoCompound extends MacroRugo {
public Equation(sVarCalc: string): Result { public Equation(sVarCalc: string): Result {
let QT: number = 0; let QT: number = 0;
let B: number = 0;
for (const child of this.children) { for (const child of this.children) {
child.Calc(sVarCalc); child.Calc(sVarCalc);
QT += child.result.vCalc; QT += child.result.vCalc;
child.result.values.xCenter = B + child.prms.B.v / 2;
B += child.prms.B.v;
} }
return new Result(QT); return new Result(QT);
} }
...@@ -104,7 +107,7 @@ export class MacrorugoCompound extends MacroRugo { ...@@ -104,7 +107,7 @@ export class MacrorugoCompound extends MacroRugo {
// Taille d'une cellule de calcul // Taille d'une cellule de calcul
const ax: number = this.prms.PBD.v / Math.sqrt(this.prms.C.v); const ax: number = this.prms.PBD.v / Math.sqrt(this.prms.C.v);
// Nombre entier de cellules et reste // Nombre entier de cellules et reste
const nCells: number = Math.floor(this.prms.BR.v / ax); let nCells: number = Math.floor(this.prms.BR.v / ax);
const xRest: number = this.prms.BR.v % ax; const xRest: number = this.prms.BR.v % ax;
const xCenters: number[] = []; const xCenters: number[] = [];
let lastBorder: number = 0; let lastBorder: number = 0;
...@@ -112,22 +115,28 @@ export class MacrorugoCompound extends MacroRugo { ...@@ -112,22 +115,28 @@ export class MacrorugoCompound extends MacroRugo {
if (xRest > ax / 2) { if (xRest > ax / 2) {
// Ajout d'une cellule à gauche // Ajout d'une cellule à gauche
xCenters.push(xRest / 4); xCenters.push(xRest / 4);
nCells++;
} else { } else {
xCenters.push((ax + xRest / 2) / 2); if (nCells < 2) {
} xCenters.push(this.prms.BR.v / 2);
lastBorder = xCenters[0] * 2; } else {
// Ajout des cellules centrales décalées de ax xCenters.push((ax + xRest / 2) / 2);
for (let i = 0; i < nCells; i++) { }
xCenters.push(lastBorder + ax / 2);
lastBorder += ax;
} }
if (xRest > ax / 2) { if (nCells > 1 || xRest > ax / 2) {
// Ajout de la cellule supplémentaire à droite lastBorder = xCenters[0] * 2;
xCenters.push(this.prms.B.v - xRest / 4); // Ajout des cellules centrales décalées de ax
} else { for (let i = 1; i < nCells; i++) {
xCenters[xCenters.length - 1] = this.prms.BR.v - (ax + xRest / 2) / 2; xCenters.push(lastBorder + ax / 2);
lastBorder += ax;
}
if (xRest > ax / 2) {
// Ajout de la cellule supplémentaire à droite
xCenters.push(this.prms.BR.v - xRest / 4);
} else {
xCenters[xCenters.length - 1] = this.prms.BR.v - (ax + xRest / 2) / 2;
}
} }
// Génération des radiers // Génération des radiers
// Suppression des radiers existants // Suppression des radiers existants
while (this.children.length > 0) { while (this.children.length > 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment