void QualEngine::init() { if (engineState != QualEngine::OPENED) return; // ... initialize node concentrations & tank volumes for (Node* node : network->nodes) { if ( network->qualModel->type == QualModel::TRACE ) node->quality = 0.0; else node->quality = node->initQual; if ( node->type() == Node::TANK ) { Tank* tank = static_cast<Tank*>(node); tank->volume = tank->findVolume(tank->initHead); } } // ... initialize reaction model and quality solver qualSolver->init(); network->qualModel->init(network); qualStep = network->option(Options::QUAL_STEP); if ( qualStep <= 0 ) qualStep = 300; qualTime = 0; engineState = QualEngine::INITIALIZED; }
int getTankValue(int param, Node* node, double* value, Network* nw) { double lcf = nw->ucf(Units::LENGTH); double vcf = lcf * lcf * lcf; *value = 0.0; if ( node->type() != Node::TANK ) return 0; Tank* tank = static_cast<Tank*>(node); switch (param) { case EN_TANKLEVEL: *value = (tank->head - tank->elev) * lcf; break; case EN_INITVOLUME: *value = tank->findVolume(tank->head) * vcf; break; case EN_MIXMODEL: *value = tank->mixingModel.type; break; case EN_MIXZONEVOL: *value = (tank->mixingModel.fracMixed * tank->maxVolume) * vcf; break; case EN_TANKDIAM: *value = tank->diameter * lcf; break; case EN_MINVOLUME: *value = tank->minVolume * vcf; break; case EN_VOLCURVE: if ( tank->volCurve ) { string name = tank->volCurve->name; int index = nw->indexOf(Element::CURVE, name); *value = index; if ( index < 0 ) return 205; } else *value = -1.0; break; case EN_MINLEVEL: *value = (tank->minHead - tank->elev) * lcf; break; case EN_MAXLEVEL: *value = (tank->maxHead - tank->elev) * lcf; break; case EN_MIXFRACTION: *value = tank->mixingModel.fracMixed; break; case EN_TANK_KBULK: *value = tank->bulkCoeff ; break; case EN_TANKVOLUME: *value = tank->volume * vcf; break; default: return 203; } return 0; }