diff --git a/src/section/hauteur.ts b/src/section/hauteur.ts new file mode 100644 index 0000000000000000000000000000000000000000..a3ebbc060a3565680ac7783c501a3b4a7c852f55 --- /dev/null +++ b/src/section/hauteur.ts @@ -0,0 +1,203 @@ +import { IParamsEquation, Debug } from "../base" +import { acSection, cParamsCanal } from "./section_type"; +import { acNewton } from "./newton"; +import { cLog } from "./log"; + +/** + * Calcul de la hauteur critique + */ +export class cHautCritique extends acNewton { + private Sn: acSection; + private oP: cParamsCanal; + /** + * Constructeur de la classe + * @param oSn Section sur laquelle on fait le calcul + * @param oP Paramètres supplémentaires (Débit, précision...) + */ + constructor(Sn: acSection, oP: cParamsCanal) { + super(oP); + this.Sn = Sn; + this.oP = oP; + + } + /** + * Calcul de la fonction dont on cherche le zéro + * @param rX Variable dont dépend la fonction + */ + CalcFn(rX) { + // Calcul de la fonction + if (this.Sn.Calc('S', rX) != 0) { + var Fn = (Math.pow(this.oP.v.Q, 2) * this.Sn.Calc('B', rX) / Math.pow(this.Sn.Calc('S', rX), 3) / cParamsCanal.G - 1); + } + else { + Fn = Infinity; + } + return Fn; + } + /** + * Calcul analytique de la dérivée de la fonction dont on cherche le zéro + * @param rX Variable dont dépend la fonction + */ + CalcDer(rX) { + if (this.Sn.Calc('S') != 0) { + // L'initialisation à partir de rX a été faite lors de l'appel à CalcFn + var Der = (this.Sn.Calc('dB') * this.Sn.Calc('S') - 3 * this.Sn.Calc('B') * this.Sn.Calc('B')); + Der = Math.pow(this.oP.v.Q, 2) / cParamsCanal.G * Der / Math.pow(this.Sn.Calc('S'), 4); + } + else { + Der = Infinity; + } + //spip_log('cHautCritique:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); + return Der; + } +} +/** + * Calcul de la hauteur normale + */ +export class cHautNormale extends acNewton { + private Sn: acSection; + private Q: number; + private Ks: number; + private If: number; + /** + * Constructeur de la classe + * @param oSn Section sur laquelle on fait le calcul + * @param oP Paramètres supplémentaires (Débit, précision...) + */ + constructor(Sn: acSection, oP: cParamsCanal) { + super(oP); + this.Sn = Sn; + this.Q = oP.v.Q; + this.Ks = oP.v.Ks; + this.If = oP.v.If; + } + /** + * Calcul de la fonction dont on cherche le zéro + * @param rX Variable dont dépend la fonction + */ + CalcFn(rX) { + // Calcul de la fonction + var Fn = (this.Q - this.Ks * Math.pow(this.Sn.Calc('R', rX), 2 / 3) * this.Sn.Calc('S', rX) * Math.sqrt(this.If)); + return Fn; + } + /** + * Calcul analytique de la dérivée de la fonction dont on cherche le zéro + * @param rX Variable dont dépend la fonction + */ + CalcDer(rX) { + // L'initialisation a été faite lors de l'appel à CalcFn + var Der = 2 / 3 * this.Sn.Calc('dR') * Math.pow(this.Sn.Calc('R'), -1 / 3) * this.Sn.Calc('S'); + Der = Der + Math.pow(this.Sn.Calc('R'), 2 / 3) * this.Sn.Calc('B'); + Der = Der * -this.Ks * Math.sqrt(this.If); + //spip_log('cHautNormale:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); + return Der; + } +} +/** + * Calcul de la hauteur correspondante (charge égale) + */ +export class cHautCorrespondante extends acNewton { + private Y: number; // Tirant d'eau connu + private rS2: number; // 1/S^2 associé au tirant d'eau connu + private Sn: acSection; // Section contenant les données de la section avec la hauteur à calculer + private rQ2G: number; // Constante de gravité + /** + * Constructeur de la classe + * @param oSn Section sur laquelle on fait le calcul + * @param oP Paramètres supplémentaires (Débit, précision...) + */ + constructor(Sn: acSection, oP: cParamsCanal) { + super(oP); + this.Y = Sn.v.Y; + this.rS2 = Math.pow(Sn.Calc('S'), -2); + this.Sn = Sn; + this.rQ2G = Math.pow(oP.v.Q, 2) / (2 * cParamsCanal.G); + } + /** + * Calcul de la fonction dont on cherche le zéro + * @param rX Variable dont dépend la fonction + */ + CalcFn(rX) { + // Calcul de la fonction + var Fn = this.Y - rX + (this.rS2 - Math.pow(this.Sn.Calc('S', rX), -2)) * this.rQ2G; + //~ spip_log('cHautCorrespondante:CalcFn('.rX.')='.rFn,'hydraulic.'._LOG_DEBUG); + return Fn; + } + /** + * Calcul analytique de la dérivée de la fonction dont on protected function cherche le zéro + * @param rX Variable dont dépend la fonction + */ + CalcDer(rX) { + // L'initialisation a été faite lors de l'appel à CalcFn + if (this.Sn.Calc('S') != 0) { + var Der = -1 + 2 * this.rQ2G * this.Sn.Calc('B') / Math.pow(this.Sn.Calc('S'), 3); + } + else { + Der = Infinity; + } + //~ spip_log('cHautCorrespondante:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); + return Der; + } +} +/** + * Calcul de la hauteur conjuguée (Impulsion égale) + */ +export class cHautConjuguee extends acNewton { + /** Tirant d'eau connu */ + private Y: number; + /** 1/S^2 associé au tirant d'eau connu */ + private rS2: number; + /** Section contenant les données de la section avec la hauteur à calculer */ + private Sn: acSection; + /** Carré du débit */ + private rQ2: number; + /** Surface hydraulique associée au tirant d'eau connu */ + private rS: number; + /** SYg associée au tirant d'eau connu */ + private rSYg: number; + /** + * Constructeur de la classe + * @param oSn Section sur laquelle on fait le calcul + * @param oP Paramètres supplémentaires (Débit, précision...) + */ + constructor(oSn: acSection, oP: cParamsCanal) { + super(oP); + this.Y = oSn.v.Y; + this.rQ2 = Math.pow(oP.v.Q, 2); + this.Sn = oSn; + this.rS = oSn.Calc('S'); + this.rSYg = oSn.Calc('SYg'); + } + /** + * Calcul de la fonction dont on cherche le zéro + * @param rX Variable dont dépend la fonction + */ + CalcFn(rX) { + // Réinitialisation des paramètres hydrauliques de oSn avec l'appel this->oSn->Calc('S',rX) + if (this.rS > 0 && this.Sn.Calc('S', rX) > 0) { + var Fn = this.rQ2 * (1 / this.rS - 1 / this.Sn.Calc('S')); + Fn = Fn + cParamsCanal.G * (this.rSYg - this.Sn.Calc('SYg')); + } + else { + Fn = -Infinity; + } + //~ spip_log('cHautConjuguee:CalcFn('.rX.')='.rFn,'hydraulic.'._LOG_DEBUG); + return Fn; + } + /** + * Calcul analytique de la dérivée de la fonction dont on cherche le zéro + * @param rX Variable dont dépend la fonction + */ + CalcDer(rX) { + // L'initialisation a été faite lors de l'appel à CalcFn + if (this.rS > 0 && this.Sn.Calc('S') > 0) { + var Der = this.rQ2 * this.Sn.Calc('dS') * Math.pow(this.Sn.Calc('S'), -2); + Der = Der - cParamsCanal.G * this.Sn.Calc('dSYg', rX); + } + else { + Der = -Infinity; + } + //~ spip_log('cHautConjuguee:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); + return Der; + } +} diff --git a/src/section/section_type.ts b/src/section/section_type.ts index 33a1cbee91a0caf82708ca3125aa01b439cf47f0..fcb296e3ddcf008a89de810e8d915e06b1e2fdf6 100644 --- a/src/section/section_type.ts +++ b/src/section/section_type.ts @@ -1,206 +1,8 @@ import { IParamsEquation, Debug } from "../base" import { acNewton } from "./newton"; +import { cHautCritique, cHautNormale, cHautCorrespondante, cHautConjuguee } from "./hauteur"; import { cLog } from "./log"; -/** - * Calcul de la hauteur critique - */ -export class cHautCritique extends acNewton { - private Sn: acSection; - private oP: cParamsCanal; - /** - * Constructeur de la classe - * @param oSn Section sur laquelle on fait le calcul - * @param oP Paramètres supplémentaires (Débit, précision...) - */ - constructor(Sn: acSection, oP: cParamsCanal) { - super(oP); - this.Sn = Sn; - this.oP = oP; - - } - /** - * Calcul de la fonction dont on cherche le zéro - * @param rX Variable dont dépend la fonction - */ - CalcFn(rX) { - // Calcul de la fonction - if (this.Sn.Calc('S', rX) != 0) { - var Fn = (Math.pow(this.oP.v.Q, 2) * this.Sn.Calc('B', rX) / Math.pow(this.Sn.Calc('S', rX), 3) / cParamsCanal.G - 1); - } - else { - Fn = Infinity; - } - return Fn; - } - /** - * Calcul analytique de la dérivée de la fonction dont on cherche le zéro - * @param rX Variable dont dépend la fonction - */ - CalcDer(rX) { - if (this.Sn.Calc('S') != 0) { - // L'initialisation à partir de rX a été faite lors de l'appel à CalcFn - var Der = (this.Sn.Calc('dB') * this.Sn.Calc('S') - 3 * this.Sn.Calc('B') * this.Sn.Calc('B')); - Der = Math.pow(this.oP.v.Q, 2) / cParamsCanal.G * Der / Math.pow(this.Sn.Calc('S'), 4); - } - else { - Der = Infinity; - } - //spip_log('cHautCritique:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); - return Der; - } -} -/** - * Calcul de la hauteur normale - */ -export class cHautNormale extends acNewton { - private Sn: acSection; - private Q: number; - private Ks: number; - private If: number; - /** - * Constructeur de la classe - * @param oSn Section sur laquelle on fait le calcul - * @param oP Paramètres supplémentaires (Débit, précision...) - */ - constructor(Sn: acSection, oP: cParamsCanal) { - super(oP); - this.Sn = Sn; - this.Q = oP.v.Q; - this.Ks = oP.v.Ks; - this.If = oP.v.If; - } - /** - * Calcul de la fonction dont on cherche le zéro - * @param rX Variable dont dépend la fonction - */ - CalcFn(rX) { - // Calcul de la fonction - var Fn = (this.Q - this.Ks * Math.pow(this.Sn.Calc('R', rX), 2 / 3) * this.Sn.Calc('S', rX) * Math.sqrt(this.If)); - return Fn; - } - /** - * Calcul analytique de la dérivée de la fonction dont on cherche le zéro - * @param rX Variable dont dépend la fonction - */ - CalcDer(rX) { - // L'initialisation a été faite lors de l'appel à CalcFn - var Der = 2 / 3 * this.Sn.Calc('dR') * Math.pow(this.Sn.Calc('R'), -1 / 3) * this.Sn.Calc('S'); - Der = Der + Math.pow(this.Sn.Calc('R'), 2 / 3) * this.Sn.Calc('B'); - Der = Der * -this.Ks * Math.sqrt(this.If); - //spip_log('cHautNormale:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); - return Der; - } -} -/** - * Calcul de la hauteur correspondante (charge égale) - */ -export class cHautCorrespondante extends acNewton { - private Y: number; // Tirant d'eau connu - private rS2: number; // 1/S^2 associé au tirant d'eau connu - private Sn: acSection; // Section contenant les données de la section avec la hauteur à calculer - private rQ2G: number; // Constante de gravité - /** - * Constructeur de la classe - * @param oSn Section sur laquelle on fait le calcul - * @param oP Paramètres supplémentaires (Débit, précision...) - */ - constructor(Sn: acSection, oP: cParamsCanal) { - super(oP); - this.Y = Sn.v.Y; - this.rS2 = Math.pow(Sn.Calc('S'), -2); - this.Sn = Sn; - this.rQ2G = Math.pow(oP.v.Q, 2) / (2 * cParamsCanal.G); - } - /** - * Calcul de la fonction dont on cherche le zéro - * @param rX Variable dont dépend la fonction - */ - CalcFn(rX) { - // Calcul de la fonction - var Fn = this.Y - rX + (this.rS2 - Math.pow(this.Sn.Calc('S', rX), -2)) * this.rQ2G; - //~ spip_log('cHautCorrespondante:CalcFn('.rX.')='.rFn,'hydraulic.'._LOG_DEBUG); - return Fn; - } - /** - * Calcul analytique de la dérivée de la fonction dont on protected function cherche le zéro - * @param rX Variable dont dépend la fonction - */ - CalcDer(rX) { - // L'initialisation a été faite lors de l'appel à CalcFn - if (this.Sn.Calc('S') != 0) { - var Der = -1 + 2 * this.rQ2G * this.Sn.Calc('B') / Math.pow(this.Sn.Calc('S'), 3); - } - else { - Der = Infinity; - } - //~ spip_log('cHautCorrespondante:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); - return Der; - } -} -/** - * Calcul de la hauteur conjuguée (Impulsion égale) - */ -export class cHautConjuguee extends acNewton { - /** Tirant d'eau connu */ - private Y: number; - /** 1/S^2 associé au tirant d'eau connu */ - private rS2: number; - /** Section contenant les données de la section avec la hauteur à calculer */ - private Sn: acSection; - /** Carré du débit */ - private rQ2: number; - /** Surface hydraulique associée au tirant d'eau connu */ - private rS: number; - /** SYg associée au tirant d'eau connu */ - private rSYg: number; - /** - * Constructeur de la classe - * @param oSn Section sur laquelle on fait le calcul - * @param oP Paramètres supplémentaires (Débit, précision...) - */ - constructor(oSn: acSection, oP: cParamsCanal) { - super(oP); - this.Y = oSn.v.Y; - this.rQ2 = Math.pow(oP.v.Q, 2); - this.Sn = oSn; - this.rS = oSn.Calc('S'); - this.rSYg = oSn.Calc('SYg'); - } - /** - * Calcul de la fonction dont on cherche le zéro - * @param rX Variable dont dépend la fonction - */ - CalcFn(rX) { - // Réinitialisation des paramètres hydrauliques de oSn avec l'appel this->oSn->Calc('S',rX) - if (this.rS > 0 && this.Sn.Calc('S', rX) > 0) { - var Fn = this.rQ2 * (1 / this.rS - 1 / this.Sn.Calc('S')); - Fn = Fn + cParamsCanal.G * (this.rSYg - this.Sn.Calc('SYg')); - } - else { - Fn = -Infinity; - } - //~ spip_log('cHautConjuguee:CalcFn('.rX.')='.rFn,'hydraulic.'._LOG_DEBUG); - return Fn; - } - /** - * Calcul analytique de la dérivée de la fonction dont on cherche le zéro - * @param rX Variable dont dépend la fonction - */ - CalcDer(rX) { - // L'initialisation a été faite lors de l'appel à CalcFn - if (this.rS > 0 && this.Sn.Calc('S') > 0) { - var Der = this.rQ2 * this.Sn.Calc('dS') * Math.pow(this.Sn.Calc('S'), -2); - Der = Der - cParamsCanal.G * this.Sn.Calc('dSYg', rX); - } - else { - Der = -Infinity; - } - //~ spip_log('cHautConjuguee:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); - return Der; - } -} - /** * Gestion des Paramètres du canal (hors section) */