freq = $freq; $this->fan = $fan; $this->op = new OperatingConditions($opInit); $this->fi = $fi; $this->impellerMaterial = $impellerMaterial; /*dd($fan[0]); $this->d2 = $fan->d2; $this->d2Org = $fan->d2; $this->costIndex = $fan->costIndex; $this->rho = $this->op->density; $this->m3s = $this->op->flow / 3600; $this->inletA = (pi() / 4 * pow($fan->inletD, 2)); $this->airSpeed = $this->m3s / $this->inletA; $this->op->setDyamicPressure($this->airSpeed); $desiredPd = 150 + 0.26 + $this->op->ptStd; $this->desireAirSpeed = sqrt($desiredPd * 2 / 1.205); if ($this->airSpeed > $this->desireAirSpeed + 10 || $this->airSpeed < $this->desireAirSpeed - 10 || $this->airSpeed < $this->desireAirSpeed * 2 / 3) { echo "air speed warning!"; } $this->fanName = $fan->name; $this->fanNameOrg = $fan->name; $this->q = $this->op->flow; $this->pt = $this->op->ptStd; $this->maxRPM = $fan->revmax; */ $this->findRPM(); } /** * @return mixed */ public function isFanAccepted() { return $this->fanAccepted; } /** * */ public function findRPM() { try { $pFunc = $this->PzeroFunctionOfNatOPQ(1); // TODO not sure what this does $nOut = Helpers::quadraticRootFinder($pFunc, 1, 10000, 'root1'); $eta = $this->etaAsFunctionOfOP($this->op->ptStd, $this->op->flow, $nOut); $this->op->setOperation($nOut, $eta); $this->efficiency = $eta; $this->rpm = $nOut; $this->power = $this->op->power; $impellerStrength = new ImpellerStrength($this->fan, $this->impellerMaterial, $this->op->temperature); $natFreq = false; if (($nOut > 3300 * ($this->freq / 60) && $nOut <= 3700 * ($this->freq / 60)) || ($nOut > 1650 * ($this->freq / 60) && $nOut <= 1850 * ($this->freq / 60)) || ($nOut > 1050 * ($this->freq / 60) && $nOut <= 1250 * ($this->freq / 60)) || ($nOut > 690 * ($this->freq / 60) && $nOut <= 780 * ($this->freq / 60)) || $this->fi == true) { $natFreq = true; } if ($impellerStrength->getMaxRPM() < $nOut) { $this->fan->bladeThickness = $this->fan->frontPlateThickness; $impellerStrength = new ImpellerStrength($this->fan, $this->impellerMaterial, $this->op->temperature, true); $this->comment .= "High speed impeller! "; $this->costIndex = $this->costIndex * 1.25; } $revMaxShown = 1.25 * $this->fan->revmax; if ($impellerStrength->getMaxRPM() >= $nOut && ($revMaxShown >= $nOut && $this->fan->revmin <= $nOut) && ($this->efficiency >= min($this->fan->eta) && $natFreq)) { if ($nOut > $this->fan->revmax) $this->comment .= "High RPM! "; $this->boundaries(); if ($this->q < $this->qMaxp) $this->comment .= "Curve position warning."; } } catch (Exception $ex) { throw new Exception($ex); } } public function boundaries() { return; } /** * @param $Q * @param $n * @return float|int */ public function PasFunctionOfQandN($Q, $n) { if ($n == 0) return 0; $nPoints = count($this->fan->q); $q_m = $this->fan->q; $p_m = $this->fan->pt; $q = []; $p = []; for ($i = 0; $i < $nPoints; $i++) { $q[$i] = $q_m[$i] * ($n / $this->fan->rev); $p[$i] = $p_m[$i] * pow($n / $this->fan->rev, 2); } $coeffs = new Polynomial([$q, $p]); $coeffs = $coeffs->getCoefficients(); dd($coeffs); dd($coeffs[0] + $coeffs[1] * $Q + $coeffs[2] * pow($Q, 2)); return $coeffs[0][0] + $coeffs[1][0] * $Q + $coeffs[2] * pow($Q, 2); } /** * @param $n1 * @return float|int */ private function PzeroFunctionOfNatOPQ($n1) { return $this->PasFunctionOfQandN($this->op->flow, $n1) - $this->op->ptStd; } /** * @param $d2 * @return float|int */ private function PzeroFunctionOfd2atOPQ($d2) { return $this->PasFunctionOfQandN($this->op->flow, $d2) - $this->op->ptStd; } /** * // todo not being used, remove later * * @param $pt * @param $q * @param $nOut * @return float|int */ public function findEta($pt, $q, $nOut) { return $this->etaAsFunctionOfOP($q, $nOut); } /** * @param $phi * @return float|int|Polynomial */ private function etaAsFunctionOfPhi($phi) { return !$phi ? 0 : $this->fan->etaPhiCoeffs[0] + $this->fan->etaPhiCoeffs * $phi + $this->fan->etaPhiCoeffs[2] * pow($phi, 2); } /** * @param $delta4 * @return float */ private function phiAsFunctionOfDelta4($delta4) { return $this->fan->phiDelta4Coeffs[0] + $this->fan->phiDelta4Coeffs[1] * log($delta4); } /** * @param $pt TODO why is $pt being passed into this function if it's not being used? * @param $q * @param $n * @return float|int */ public function etaAsFunctionOfOP($q, $n) { if ($n == 0) return 0; $eta = $this->fan->eta; $coeffs = new Polynomial([$q, $eta]); return $coeffs[0] + $coeffs[1] * $this->q + $coeffs[2] * pow($this->q, 2); } /** * @param $rpm */ public function setDiameter($rpm) { $this->rpm = $rpm; } }