Skip to content
Snippets Groups Projects
Commit 82259eb0 authored by David Dorchies's avatar David Dorchies Committed by mathias.chouet
Browse files

#35 Debug inclined apron discretisation

parent 323dff5a
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ import { MacrorugoCompound } from "../../src/macrorugo/macrorugo_compound";
import { Props } from "../../src/props";
import { Session } from "../../src/session";
let B: number;
let BR: number;
describe("MacroRugoCompound", () => {
describe("Default 1 apron", () => {
......@@ -20,22 +20,32 @@ describe("MacroRugoCompound", () => {
});
describe("Default inclined but flat apron", () => {
beforeAll(() => {
B = 2;
BR = 0;
});
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`, () => {
const mrc = Session.getInstance().createNub(
new Props({ calcType: CalculatorType.MacroRugoCompound })
) as MacrorugoCompound;
mrc.properties.setPropValue("InclinedApron", true);
mrc.prms.B.singleValue = 4;
mrc.prms.BR.singleValue = BR;
const mr = Session.getInstance()
.createNub(new Props({ calcType: CalculatorType.MacroRugo })) as MacroRugo;
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 {
public Equation(sVarCalc: string): Result {
let QT: number = 0;
let B: number = 0;
for (const child of this.children) {
child.Calc(sVarCalc);
QT += child.result.vCalc;
child.result.values.xCenter = B + child.prms.B.v / 2;
B += child.prms.B.v;
}
return new Result(QT);
}
......@@ -104,7 +107,7 @@ export class MacrorugoCompound extends MacroRugo {
// Taille d'une cellule de calcul
const ax: number = this.prms.PBD.v / Math.sqrt(this.prms.C.v);
// 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 xCenters: number[] = [];
let lastBorder: number = 0;
......@@ -112,22 +115,28 @@ export class MacrorugoCompound extends MacroRugo {
if (xRest > ax / 2) {
// Ajout d'une cellule à gauche
xCenters.push(xRest / 4);
nCells++;
} else {
xCenters.push((ax + xRest / 2) / 2);
}
lastBorder = xCenters[0] * 2;
// Ajout des cellules centrales décalées de ax
for (let i = 0; i < nCells; i++) {
xCenters.push(lastBorder + ax / 2);
lastBorder += ax;
if (nCells < 2) {
xCenters.push(this.prms.BR.v / 2);
} else {
xCenters.push((ax + xRest / 2) / 2);
}
}
if (xRest > ax / 2) {
// Ajout de la cellule supplémentaire à droite
xCenters.push(this.prms.B.v - xRest / 4);
} else {
xCenters[xCenters.length - 1] = this.prms.BR.v - (ax + xRest / 2) / 2;
if (nCells > 1 || xRest > ax / 2) {
lastBorder = xCenters[0] * 2;
// Ajout des cellules centrales décalées de ax
for (let i = 1; i < nCells; i++) {
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
// Suppression des radiers existants
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