62 $res = $this->objet->$sFnCalculQ();
66 if(self::DBG) spip_log(
'CalculQ('.$this->objet->VarCal.
')='.$res[0],
'hydraulic',_LOG_DEBUG);
77 public function calculer($QT,$rTol,$rInit=0.) {
78 if(self::DBG) spip_log(
"Dichotomie->calculer($QT,$rTol,$rInit)",
'hydraulic.'._LOG_DEBUG);
79 $this->objet->VarCal = $rInit;
80 list($Q,$nFlag) = $this->
CalculQ();
82 $this->objet->VarCal = $XminInit;
83 list($Q1,$nFlag) = $this->
CalculQ();
84 if($Q1 < $Q xor $Q > $QT) $Q1 = $Q;
85 $XmaxInit = max(1,$rInit)*100;
86 $this->objet->VarCal = $XmaxInit;
87 list($Q2,$nFlag) = $this->
CalculQ();
88 if($QT < $Q xor $Q > $Q2) $Q1 = $Q;
89 $DX = ($XmaxInit - $XminInit) / floatval(self::IDEFINT);
90 $nIterMax = floor(max($XmaxInit - $rInit,$rInit - $XminInit) / $DX + 1);
91 if(self::DBG) spip_log(
"QT=$QT nIterMax=$nIterMax XminInit=$XminInit XmaxInit=$XmaxInit DX=$DX",
'hydraulic',_LOG_DEBUG);
96 $this->objet->VarCal = $rInit;
97 list($Q,$nFlag) = $this->
CalculQ();
102 for($nIter=1;$nIter<=$nIterMax;$nIter++) {
105 if($Xmax > $XmaxInit xor $DX <= 0) $Xmax = $XmaxInit;
106 $this->objet->VarCal = $Xmax;
107 list($Q,$nFlag) = $this->
CalculQ();
108 if($Q1 < $Q2 xor $Q <= $Q2) {
112 if($Q1 < $Q2 xor $Q >= $Q1) {
117 if($Xmin < $XminInit xor $DX <= 0) {
120 $this->objet->VarCal = $Xmin;
121 list($Q,$nFlag) = $this->
CalculQ();
122 if($Q1 < $Q2 xor $Q <= $Q2) {
126 if($Q1 < $Q2 xor $Q >= $Q1) {
131 if(self::DBG) spip_log(
"nIter=$nIter Xmin=$Xmin Xmax=$Xmax",
'hydraulic',_LOG_DEBUG);
132 if(self::DBG) spip_log(
"X1=$X1 Q1=$Q1 X2=$X2 Q2=$Q2",
'hydraulic',_LOG_DEBUG);
133 if(self::DBG) spip_log(
'$QT > $Q1 xor $QT >= $Q2 = '.($QT > $Q1 xor $QT >= $Q2),
'hydraulic',_LOG_DEBUG);
135 if($QT > $Q1 xor $QT >= $Q2) {
break;}
138 if($nIter >= self::IDEFINT) {
140 if($Q2 < $QT and $Q1 < $QT) {
142 $this->objet->VarCal = $XmaxInit;
146 $this->objet->VarCal = $XminInit;
148 list($Q,$nFlag) = $this->
CalculQ();
150 if($this->bLogError) {
151 $sLog = ($Q1<$Q2)?
"Q($X1)=$Q1 < Q($X2)=$Q2":
"Q($X2)=$Q2 < Q($X1)=$Q1";
152 $sLog = ($QT<$Q1)?
"$QT < $sLog":
"$sLog < $QT";
153 $this->oLog->Add(_T(
'hydraulic:dichotomie_intervalle').
' : '.
161 for($nIter = 1; $nIter<=self::IDICMAX;$nIter++) {
162 $this->objet->VarCal=$X;
163 if(self::DBG) spip_log(
"nIter=$nIter nFlag=$nFlag".
' rVarC='.$this->objet->VarCal,
'hydraulic',_LOG_DEBUG);
164 list($Q,$nFlag) = $this->
CalculQ();
166 if($QT!=0 && abs($X1-$X2) <= $rTol) {
break;}
167 if($QT < $Q xor $Q1 <= $Q2) {
169 $X1=$this->objet->VarCal;
173 $X2=$this->objet->VarCal;
177 if($nIter == self::IDICMAX) {
179 _T(
'hydraulic:dichotomie_non_convergence').
' '.
format_nombre($Q, $this->data[
'iPrec']),
184 if(self::DBG) spip_log(
'rVarC='.$this->objet->VarCal.
" nFlag=$nFlag",
'hydraulic.'._LOG_DEBUG);
185 return array($this->objet->VarCal,$nFlag);
calculer($QT, $rTol, $rInit=0.)
Calcul à l'ouvrage.
$oLog
Pour loguer les messages de debug de cette classe.
$bLogError
Nom de la méthode de calcul du débit.
__construct(&$oLog, &$objet, $sFnCalculQ, $bLogError=true)
true pour afficher les messages d'erreur en cas de non convergence
$objet
Itérations maximum de la dichotomie.
format_nombre($nombre, $dec)
const IDICMAX
Pas de parcours de l'intervalle pour initialisation dichotomie.