Beispiel #1
0
void Mash::setStepWeight(int i, double w){
    // you can only set the weight on a cereal mash step
    MashStep *s = (&steps[i]);
    if (s->getMethod() == CEREAL_MASH){
        double w2 = Quantity::convertUnit(this->maltUnits, CONVERTER_LB, w);
        s->setWeightLbs(w2);
        calcMashSchedule();
    }
}
Beispiel #2
0
// mash step methods:
int Mash::setStepType(int i, QString t){
    if (steps.size() < i || steps.empty())
        return -1;
    MashStep *ms = &steps[i];
    ms->setType(t);
    ms->setStartTemp(calcStepTemp(t));
    ms->setEndTemp(calcStepTemp(t));
    return 0;
}
Beispiel #3
0
void Mash::setStepEndTemp(int i, double t){
    if (i == 0) {
        return;
    }
    MashStep *ms = &steps[i];
    if (tempUnits == "C")
        ms->setEndTemp(BrewCalcs::cToF(t));
    else
        ms->setEndTemp(t);
    calcMashSchedule();
}
QVariant MashStepTableModel::data( const QModelIndex& index, int role ) const
{
   MashStep* row;
   unitDisplay unit;
   unitScale scale;
   int col = index.column();

   if( mashObs == 0 )
      return QVariant();

   // Ensure the row is ok.
   if( index.row() >= (int)(steps.size()) )
   {
      Brewtarget::logW(tr("Bad model index. row = %1").arg(index.row()));
      return QVariant();
   }
   else
      row = steps[index.row()];

   // Make sure we only respond to the DisplayRole role.
   if( role != Qt::DisplayRole )
      return QVariant();

   switch( col )
   {
      case MASHSTEPNAMECOL:
         return QVariant(row->name());
      case MASHSTEPTYPECOL:
         return QVariant(row->typeStringTr());
      case MASHSTEPAMOUNTCOL:

         unit = displayUnit(col);
         scale = displayScale(col);

         return (row->type() == MashStep::Decoction)
                ? QVariant( Brewtarget::displayAmount(row->decoctionAmount_l(), Units::liters, 3, unit, scale ) )
                : QVariant( Brewtarget::displayAmount(row->infuseAmount_l(), Units::liters, 3, unit, scale) );
      case MASHSTEPTEMPCOL:
         unit = displayUnit(col);
         return (row->type() == MashStep::Decoction)
                ? QVariant("---")
                : QVariant( Brewtarget::displayAmount(row->infuseTemp_c(), Units::celsius, 3, unit, noScale) );
      case MASHSTEPTARGETTEMPCOL:
         unit = displayUnit(col);
         return QVariant( Brewtarget::displayAmount(row->stepTemp_c(), Units::celsius,3, unit, noScale) );
      case MASHSTEPTIMECOL:
         scale = displayScale(col);
         return QVariant( Brewtarget::displayAmount(row->stepTime_min(), Units::minutes,0,noUnit,scale) );
      default :
         Brewtarget::logW(tr("Bad column: %1").arg(index.column()));
         return QVariant();
   }
}
Beispiel #5
0
void Mash::setStepStartTempF(int i, double t){
    if (tempUnits == "C"){
        t = BrewCalcs::cToF(t);
    }
    MashStep *ms = &steps[i];
    ms->setStartTemp(t);
    double tLoss = getTunLoss() * (ms->getMinutes()/60);
    ms->setEndTemp(t - tLoss);
    ms->setType(calcStepType(t));

    calcMashSchedule();
}
Beispiel #6
0
double Mash::totalTime()
{
   int i, size;
   double totalTime = 0.0;
   QList<MashStep*> steps = mashSteps();
   MashStep* mstep;

   size = steps.size();
   for( i = 0; i < size; ++i )
   {
      mstep = steps[i];
      totalTime += mstep->stepTime_min();
   }
   return totalTime;
}
Beispiel #7
0
// === other methods ===
double Mash::totalMashWater_l()
{
   int i, size;
   double waterAdded_l = 0.0;
   QList<MashStep*> steps = mashSteps();
   MashStep* step;
   
   size = steps.size();
   for( i = 0; i < size; ++i )
   {
      step = steps[i];
      
      if( step->isInfusion() )
         waterAdded_l += step->infuseAmount_l();
   }
   
   return waterAdded_l;
}
Beispiel #8
0
int Mash::addStep(){
    MashStep step;
    // calcStepType(temp);
    if (!steps.empty()) {
        MashStep *lastStep = &steps[steps.size() -1];
        step.setStartTemp(lastStep->getEndTemp() + 1);
        step.setEndTemp(step.getStartTemp());
        step.setType(calcStepType(step.getStartTemp()));
    }

    steps.append(step);
    int i = steps.size();
    calcMashSchedule();
    // return the index of the last added step:
    return i-1;

}
Beispiel #9
0
bool operator==(MashStep &m1, MashStep &m2)
{
   return m1.name() == m2.name();
}
Beispiel #10
0
bool operator<(MashStep &m1, MashStep &m2)
{
   return m1.name() < m2.name();
}
bool MashStepTableModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
   MashStep *row;
   unitDisplay unit;

   if( mashObs == 0 )
      return false;

   if( index.row() >= (int)(steps.size()) || role != Qt::EditRole )
      return false;
   else
      row = steps[index.row()];

   switch( index.column() )
   {
      case MASHSTEPNAMECOL:
         if( value.canConvert(QVariant::String))
         {
            row->setName(value.toString());
            return true;
         }
         else
            return false;
      case MASHSTEPTYPECOL:
         if( value.canConvert(QVariant::Int) )
         {
            row->setType(static_cast<MashStep::Type>(value.toInt()));
            return true;
         }
         else
            return false;
      case MASHSTEPAMOUNTCOL:
         if( value.canConvert(QVariant::String) )
         {
            unit = displayUnit(MASHSTEPAMOUNTCOL);
            if( row->type() == MashStep::Decoction )
               row->setDecoctionAmount_l( Brewtarget::qStringToSI(value.toString(),Units::liters,unit) );
            else
               row->setInfuseAmount_l( Brewtarget::qStringToSI(value.toString(),Units::liters,unit) );
            return true;
         }
         else
            return false;
      case MASHSTEPTEMPCOL:
         if( value.canConvert(QVariant::String) && row->type() != MashStep::Decoction )
         {
            unit = displayUnit(MASHSTEPTEMPCOL);
            row->setInfuseTemp_c( Brewtarget::qStringToSI(value.toString(),Units::celsius,unit) );
            return true;
         }
         else
            return false;
      case MASHSTEPTARGETTEMPCOL:
         if( value.canConvert(QVariant::String) )
         {
            unit = displayUnit(MASHSTEPTARGETTEMPCOL);
            row->setStepTemp_c( Brewtarget::qStringToSI(value.toString(),Units::celsius,unit) );
            row->setEndTemp_c( Brewtarget::qStringToSI(value.toString(),Units::celsius,unit) );
            return true;
         }
         else
            return false;
      case MASHSTEPTIMECOL:
         if( value.canConvert(QVariant::String) )
         {
            row->setStepTime_min( Brewtarget::qStringToSI(value.toString(),Units::minutes) );
            return true;
         }
         else
            return false;
      default:
         return false;
   }
}
void ScaleRecipeTool::scale(Equipment* equip, double newEff)
{
    if( recObs == 0 || equip == 0 )
        return;

    int i, size;

    // Calculate volume ratio
    double currentBatchSize_l = recObs->batchSize_l();
    double newBatchSize_l = equip->batchSize_l();
    double volRatio = newBatchSize_l / currentBatchSize_l;

    // Calculate efficiency ratio
    double oldEfficiency = recObs->efficiency_pct();
    double effRatio = oldEfficiency / newEff;

    Database::instance().addToRecipe(recObs, equip);
    recObs->setBatchSize_l(newBatchSize_l);
    recObs->setBoilSize_l(equip->boilSize_l());
    recObs->setEfficiency_pct(newEff);
    recObs->setBoilTime_min(equip->boilTime_min());

    QList<Fermentable*> ferms = recObs->fermentables();
    size = ferms.size();
    for( i = 0; i < size; ++i )
    {
        Fermentable* ferm = ferms[i];
        // NOTE: why the hell do we need this?
        if( ferm == 0 )
            continue;

        if( !ferm->isSugar() && !ferm->isExtract() ) {
            ferm->setAmount_kg(ferm->amount_kg() * effRatio * volRatio);
        } else {
            ferm->setAmount_kg(ferm->amount_kg() * volRatio);
        }
    }

    QList<Hop*> hops = recObs->hops();
    size = hops.size();
    for( i = 0; i < size; ++i )
    {
        Hop* hop = hops[i];
        // NOTE: why the hell do we need this?
        if( hop == 0 )
            continue;

        hop->setAmount_kg(hop->amount_kg() * volRatio);
    }

    QList<Misc*> miscs = recObs->miscs();
    size = miscs.size();
    for( i = 0; i < size; ++i )
    {
        Misc* misc = miscs[i];
        // NOTE: why the hell do we need this?
        if( misc == 0 )
            continue;

        misc->setAmount( misc->amount() * volRatio );
    }

    QList<Water*> waters = recObs->waters();
    size = waters.size();
    for( i = 0; i < size; ++i )
    {
        Water* water = waters[i];
        // NOTE: why the hell do we need this?
        if( water == 0 )
            continue;

        water->setAmount_l(water->amount_l() * volRatio);
    }

    Mash* mash = recObs->mash();
    if( mash == 0 )
        return;

    QList<MashStep*> mashSteps = mash->mashSteps();
    size = mashSteps.size();
    for( i = 0; i < size; ++i )
    {
        MashStep* step = mashSteps[i];
        // NOTE: why the hell do we need this?
        if( step == 0 )
            continue;

        // Reset all these to zero so that the user
        // will know to re-run the mash wizard.
        step->setDecoctionAmount_l(0);
        step->setInfuseAmount_l(0);
    }

    // I don't think I should scale the yeasts.

    // Let the user know what happened.
    QMessageBox::information(this, tr("Recipe Scaled"),
                             tr("The equipment and mash have been reset due to the fact that mash temperatures do not scale easily. Please re-run the mash wizard.") );
}
Beispiel #13
0
 QString Mash::toXml() {

    calcMashSchedule();
    QString sb;
    sb.append("  <MASH>\n");
    sb.append(SBStringUtils::xmlElement("NAME", name, 4));
    sb.append(SBStringUtils::xmlElement("MASH_VOLUME", SBStringUtils::format(Quantity::convertUnit(CONVERTER_QT, volUnits, volQts), 2) , 4));
    sb.append(SBStringUtils::xmlElement("MASH_VOL_U", volUnits, 4));
    sb.append(SBStringUtils::xmlElement("MASH_RATIO", mashRatio, 4));
    sb.append(SBStringUtils::xmlElement("MASH_RATIO_U", mashRatioU, 4));
    sb.append(SBStringUtils::xmlElement("MASH_TIME", totalTime, 4));
    sb.append(SBStringUtils::xmlElement("MASH_TMP_U", tempUnits, 4));
    sb.append(SBStringUtils::xmlElement("THICK_DECOCT_RATIO", thickDecoctRatio, 4));
    sb.append(SBStringUtils::xmlElement("THIN_DECOCT_RATIO", thinDecoctRatio, 4));
    if (tempUnits == "C"){
        sb.append(SBStringUtils::xmlElement("MASH_TUNLOSS_TEMP", (tunLossF/1.8), 4));
        sb.append(SBStringUtils::xmlElement("GRAIN_TEMP", BrewCalcs::fToC(grainTempF), 4));
        sb.append(SBStringUtils::xmlElement("BOIL_TEMP", BrewCalcs::fToC(boilTempF), 4));
    }
    else {
        sb.append(SBStringUtils::xmlElement("MASH_TUNLOSS_TEMP", tunLossF, 4));
        sb.append(SBStringUtils::xmlElement("GRAIN_TEMP", grainTempF, 4));
        sb.append(SBStringUtils::xmlElement("BOIL_TEMP", boilTempF, 4));
    }

    for (int i = 0; i < steps.size(); i++) {
        MashStep st = steps.at(i);
        sb.append("    <ITEM>\n");
        sb.append(SBStringUtils::xmlElement("TYPE", st.getType(), 6));
        sb.append(SBStringUtils::xmlElement("TEMP", st.getStartTemp(), 6));

        double sTemp;
        double eTemp;

        if (tempUnits == "C") {
            sTemp = BrewCalcs::fToC(st.getStartTemp());
            eTemp = BrewCalcs::fToC(st.getEndTemp());
        } else {
            sTemp = st.getStartTemp();
            eTemp = st.getEndTemp();
        }

        sb.append(SBStringUtils::xmlElement("DISPL_TEMP", SBStringUtils::format(sTemp, 1), 6));

        sb.append(SBStringUtils::xmlElement("END_TEMP", st.getEndTemp(), 6));
        sb.append(SBStringUtils::xmlElement("DISPL_END_TEMP", SBStringUtils::format(eTemp, 1), 6));

        sb.append(SBStringUtils::xmlElement("MIN", st.getMinutes(), 6));
        sb.append(SBStringUtils::xmlElement("RAMP_MIN", st.getRampMin(), 6));
        sb.append(SBStringUtils::xmlElement("METHOD", st.getMethod(), 6));
        sb.append(SBStringUtils::xmlElement("WEIGHT_LBS", st.getWeightLbs(), 6));
        sb.append(SBStringUtils::xmlElement("DIRECTIONS", st.getDirections(), 6));
        sb.append("    </ITEM>\n");
    }

    sb.append("  </MASH>\n");
    return sb;
}
Beispiel #14
0
void Mash::calcMashSchedule() {
    // Method to run through the mash table and calculate values
    if (!this->allowRecalcs) {
        return;
    }

    double strikeTemp = 0;
    double targetTemp = 0;
    double waterAddedQTS = 0;
    double waterEquiv = 0;
    double mr = mashRatio;
    double currentTemp = getGrainTemp();

    double displTemp = 0;
    double tunLoss; // figure out a better way to do this, eg: themal mass
    double decoct = 0;
    int totalMashTime = 0;
    int totalSpargeTime = 0;
    double mashWaterQTS = 0;
    double mashVolQTS = 0;
    int numSparge = 0;
    double totalWeightLbs = 0;
    double totalCerealLbs = 0;


    // convert mash ratio to qts/lb if in l/kg
    if (mashRatioU.compare(L_PER_KG) == 0) {
        mr *= 0.479325;
    }

    // convert CurrentTemp to F
    if (tempUnits == "C") {
        currentTemp = BrewCalcs::cToF(currentTemp);
        tunLoss = tunLossF * 1.8;
    }
    else
        tunLoss = tunLossF;

    // perform calcs on first record
    if (steps.empty())
        return;

    // sort the list
    //Collections.sort(steps);

    // add up the cereal mash lbs
    for (int i = 1; i < steps.size(); i++) {
        MashStep *stp = &steps[i];
        if (stp->getMethod() == "cereal mash"){
            totalCerealLbs += stp->getWeightLbs();
        }
    }
    totalWeightLbs = maltWeightLbs - totalCerealLbs;


    // the first step is always an infusion
    MashStep *stp = &steps[0];
    targetTemp = stp->getStartTemp();
    strikeTemp = calcStrikeTemp(targetTemp, currentTemp, mr, tunLoss);
    waterAddedQTS = mr * totalWeightLbs;
    waterEquiv = totalWeightLbs * (0.192 + mr);
    mashVolQTS = calcMashVol(totalWeightLbs, mr);
    totalMashTime += stp->getMinutes();
    mashWaterQTS += waterAddedQTS;
    stp->getInVol()->setUnits(CONVERTER_QT);
    stp->getInVol()->setAmount(waterAddedQTS);
    stp->setStrikeTemp(strikeTemp);
    stp->setMethod(INFUSION);
    stp->setWeightLbs(totalWeightLbs);

    qDebug() << "Subtracting cereal " <<  totalCerealLbs << " from " <<maltWeightLbs;
    totalWeightLbs = maltWeightLbs - totalCerealLbs;
    // subtract the water added from the Water Equiv so that they are correct when added in the next part of the loop
    waterEquiv -= waterAddedQTS;

    // Updated the water added

    if (tempUnits == "C") {
        strikeTemp = BrewCalcs::fToC(strikeTemp);
    }

    stp->setDirections("Mash in with " + SBStringUtils::format(stp->getInVol()->getValueAs(volUnits),1 ) + " " + volUnits
            + " of water at " + SBStringUtils::format(strikeTemp, 1) + " " + tempUnits);

    // set TargetTemp to the end temp
    targetTemp = stp->getEndTemp();

    for (int i = 1; i < steps.size(); i++) {
        stp = &steps[i];
        currentTemp = targetTemp; // switch
        targetTemp = stp->getStartTemp();

        // if this is a former sparge step that's been changed, change
        // the method to infusion
        qDebug() << "Mash step Type: " << stp->getType() << " Method: " << stp->getMethod();
        if (stp->getType() != SPARGE && ( stp->getMethod() == FLY || stp->getMethod() == BATCH))
                stp->setMethod(INFUSION);

        // do calcs
        if (stp->getMethod() == INFUSION) { // calculate an infusion step
            decoct = 0;
            waterEquiv += waterAddedQTS; // add previous addition to get WE
            strikeTemp = boilTempF; // boiling water

            // Updated the water added
            waterAddedQTS = calcWaterAddition(targetTemp, currentTemp,
                    waterEquiv, boilTempF);

            stp->getOutVol()->setAmount(0);
            stp->getInVol()->setUnits(CONVERTER_QT);
            stp->getInVol()->setAmount(waterAddedQTS);
            stp->setStrikeTemp(strikeTemp);
            stp->setWeightLbs(totalWeightLbs);

            if (tempUnits == "C")
                strikeTemp = 100;
            stp->setDirections("Add " + SBStringUtils::format(stp->getInVol()->getValueAs(volUnits), 1) + " " + volUnits
                    + " of water at " + SBStringUtils::format(strikeTemp, 1) + " " + tempUnits);

            mashWaterQTS += waterAddedQTS;
            mashVolQTS += waterAddedQTS;

        }

        else if (stp->getMethod() == DECOCTION) { // calculate a decoction step
            waterEquiv += waterAddedQTS; // add previous addition to get WE
            waterAddedQTS = 0;
            strikeTemp = boilTempF; // boiling water
            double ratio=0.75;

            if (stp->getMethod() == DECOCTION_THICK)
                ratio = thickDecoctRatio;
            else if (stp->getMethod() == DECOCTION_THIN)
                ratio = thinDecoctRatio;

            // Calculate volume (qts) of mash to remove
            decoct = calcDecoction2(targetTemp, currentTemp, mashWaterQTS, ratio, totalWeightLbs);
            stp->getOutVol()->setUnits(CONVERTER_QT);
            stp->getOutVol()->setAmount(decoct);
            stp->getInVol()->setAmount(0);
            stp->setStrikeTemp(boilTempF);
            stp->setWeightLbs(totalWeightLbs);

            // Updated the decoction, convert to right units & make directions
            stp->setDirections("Remove " + SBStringUtils::format(stp->getOutVol()->getValueAs(volUnits), 1) + " " + volUnits
                    + " of mash, boil, and return to mash.");

        } else if (stp->getMethod() == DIRECT) { // calculate a direct heat step
            decoct = 0;
            waterEquiv += waterAddedQTS; // add previous addition to get WE
            waterAddedQTS = 0;
            displTemp = stp->getStartTemp();
            if (tempUnits == "C")
                displTemp = BrewCalcs::fToC(displTemp);
            stp->setDirections("Add direct heat until mash reaches " + QString::number(displTemp)
                    + " " + tempUnits + ".");
            stp->getInVol()->setAmount(0);
            stp->getOutVol()->setAmount(0);
            stp->setStrikeTemp(0);
            stp->setWeightLbs(totalWeightLbs);

        } else if (stp->getMethod() == CEREAL_MASH) { // calculate a cereal mash step

            waterEquiv += waterAddedQTS; // add previous addition to get WE
            waterAddedQTS = 0;
            targetTemp = stp->getStartTemp();
            double extraWaterQTS = 0;
            double cerealTemp = boilTempF;
            double cerealTargTemp = cerealMashTemp;
            QString addStr = "";

            /*
             * 1. check the temp of the mash when you add the boiling cereal mash @ default ratio back
             * 2. if it's > than the step temp, adjust the step temp
             * 3. if it's < than the step temp, add extra water to increase the "heat equivalencey" of the cereal mash
             */

            double cerealWaterEquiv = stp->getWeightLbs() * (0.192 + mr);
            waterAddedQTS = mr * stp->getWeightLbs();
            strikeTemp = calcStrikeTemp(cerealMashTemp, grainTempF, mr, 0);

            double newTemp = ((waterEquiv * currentTemp) + (cerealWaterEquiv * cerealTemp)) / (waterEquiv + cerealWaterEquiv);

            if (newTemp > targetTemp){
                stp->setStartTemp(newTemp);
            }

            if (newTemp < targetTemp){
                double addQts = ((waterEquiv * (targetTemp - currentTemp)) / (cerealTemp - targetTemp)) - 0.192;
                extraWaterQTS = addQts - waterAddedQTS;
                addStr = " Add " + SBStringUtils::format(Quantity::convertUnit(CONVERTER_QT, volUnits, extraWaterQTS), 1)
                  + " " + volUnits + " water to the cereal mash.";
            }

            // Calculate final temp of cereal mash
            // cerealTemp = (targetTemp * (waterEquiv + cerealWaterEquiv) - (waterEquiv * currentTemp)) / cerealWaterEquiv;
            totalMashTime += stp->getMinutes();
            mashWaterQTS += waterAddedQTS + extraWaterQTS;
            stp->getInVol()->setUnits(CONVERTER_QT);
            stp->getInVol()->setAmount(waterAddedQTS);
            stp->getOutVol()->setAmount(0);
            stp->setStrikeTemp(strikeTemp);

            // make directions

            QString weightStr = SBStringUtils::format(Quantity::convertUnit(CONVERTER_LB, this->maltUnits, stp->getWeightLbs()), 1)
            + " " + this->maltUnits;
            QString volStr = SBStringUtils::format(Quantity::convertUnit(CONVERTER_QT, volUnits, waterAddedQTS), 1)
            + " " + volUnits;

            if (tempUnits == "C"){
                strikeTemp = BrewCalcs::fToC(strikeTemp);
                cerealTemp = BrewCalcs::fToC(cerealTemp);
                targetTemp = BrewCalcs::fToC(targetTemp);
                cerealTargTemp = BrewCalcs::fToC(cerealTargTemp);
            }

            QString tempStr = SBStringUtils::format(strikeTemp, 1) + tempUnits;
            QString tempStr2 = SBStringUtils::format(cerealTemp, 1) + tempUnits;
            QString tempStr3 = SBStringUtils::format(targetTemp, 1) + tempUnits;
            QString tempStr4 = SBStringUtils::format(cerealTargTemp, 1) + tempUnits;
            QString newDirection = "Cereal mash: mash " + weightStr + " grain with " + volStr + " water at " +
                tempStr + " to hit " + tempStr4 + " and rest.";
            newDirection.append(addStr);
            newDirection.append(" Raise to " +  tempStr2 + " and add to the main mash to reach " + tempStr3);

            stp->setDirections(newDirection);
            // add cereal mash to total weight
            totalWeightLbs += stp->getWeightLbs();

        } else {

            qDebug() << "Unrecognised mash step: " << stp->getMethod();
        }

        if (stp->getType() == SPARGE)
            numSparge++;
        else {
            totalMashTime += stp->getMinutes();
        }
        // set target temp to end temp for next step
        targetTemp = stp->getEndTemp();

    } // for steps.size()

    waterEquiv += waterAddedQTS; // add previous addition to get WE
    totalTime = totalMashTime;
    volQts = mashVolQTS;

    // water use stats:
    qDebug() << "Total Weight " << totalWeightLbs;
    absorbedQTS = totalWeightLbs * 0.52; // figure from HBD

    // spargeTotalQTS = (myRecipe.getPreBoilVol("qt")) - (mashWaterQTS - absorbedQTS);
    totalWaterQTS = mashWaterQTS;
    spargeQTS = this->preBoilQts -
            (mashWaterQTS - absorbedQTS - deadSpace.getValueAs(CONVERTER_QT));
    qDebug() << "Sparge QTs: " << spargeQTS;
    // Now let's figure out the sparging:
    if (numSparge == 0)
        return;

    // Amount to collect per sparge
    double col = this->preBoilQts / numSparge;
    QList<double> charge = QList<double>();
    QList<double> collect = QList<double>();

    for (int i = 0; i < numSparge; i++) {
        charge.append(0.0);
        collect.append(0.0);
    }
    double totalCollectQts = this->preBoilQts;


    // do we need to add more water to charge up
    // is the amount we need to collect less than the initial mash volume - absorbption
    if (col <= (mashWaterQTS - absorbedQTS)) {
        charge[0] = 0;
        collect[0] = mashWaterQTS - absorbedQTS; // how much is left over from the mash
        totalCollectQts = totalCollectQts - collect[0];
    } else {
        charge[0] = col - (mashWaterQTS - absorbedQTS); // add the additional water to get out the desired first collection amount PER sparge
        collect[0] = col;
        totalCollectQts = totalCollectQts - collect[0];
    }

   // do we need any more steps?
    if(numSparge > 1) {
        /*
        batch_1_sparge_liters = (boil_size_l/<total number of steps> ) - mash_water_l + grain_wt_kg * 0.625)
                batch_2_liters = boil_size_l / <total number of steps>
            */
        for (int i = 1; i < numSparge; i++) {
            charge[i] = col;
            collect[i] = col;
        }
    }

    int j=0;
    for (int i = 1; i < steps.size(); i++) {
        stp = &steps[i];
        if (stp->getType() == SPARGE) {

            stp->getInVol()->setUnits(CONVERTER_QT);
            stp->getInVol()->setAmount(charge[j]);

            stp->getOutVol()->setUnits(CONVERTER_QT);
            stp->getOutVol()->setAmount(collect[j]);

            stp->setStrikeTemp(SPARGETMPF);
            totalSpargeTime += stp->getMinutes();
            QString collectStr = SBStringUtils::format(Quantity::convertUnit(CONVERTER_QT, volUnits, collect[j]), 2) +
            " " + volUnits;
            QString tempStr = "";

            if (tempUnits == "F"){
                tempStr = "" + SBStringUtils::format(SPARGETMPF, 1) + "F";
            } else {
                tempStr = SBStringUtils::format(BrewCalcs::fToC(SPARGETMPF), 1) + "C";
            }

            if (numSparge > 1){
                stp->setMethod(BATCH);
                QString add = SBStringUtils::format(Quantity::convertUnit(CONVERTER_QT, volUnits, charge[j]), 2) +
                " " + volUnits;
                stp->setDirections("Add " + add + " at " + tempStr + " to collect " + collectStr);

            } else {
                stp->getInVol()->setUnits(CONVERTER_QT);
                stp->getInVol()->setAmount(spargeQTS);

                stp->getOutVol()->setUnits(CONVERTER_QT);
                stp->getOutVol()->setAmount(collect[j]);

                stp->setMethod(FLY);
                stp->setDirections("Sparge with " +
                        SBStringUtils::format(Quantity::convertUnit(CONVERTER_QT, volUnits, spargeQTS), 1) +
                        " " + volUnits + " at " + tempStr + " to collect " + collectStr);
            }
            j++;
        }
    }
}
Beispiel #15
0
QString Mash::getStepType(int i) {
    if (steps.size() < i || steps.empty())
        return "";
    MashStep ms = steps.at(i);
    return ms.getType();
}