if ((currentH2Consumed <= 0) || (currentCO2Consumed <= 0)) { currentH2OProduced = myAirRS.randomFilter(0f); currentCH4Produced = myAirRS.randomFilter(0f); myAirRS.getH2ProducerDefinitionImpl().pushResourceToStore( currentH2Consumed); myAirRS.getCO2ProducerDefinitionImpl().pushResourceToStore( currentCO2Consumed); } else {  float limitingReactant = Math.min(currentH2Consumed / 4f, currentCO2Consumed); if (limitingReactant == currentH2Consumed) myAirRS.getCO2ProducerDefinitionImpl().pushResourceToStore( currentCO2Consumed - limitingReactant); else myAirRS.getH2ProducerDefinitionImpl().pushResourceToStore( currentH2Consumed - 4f * limitingReactant); float waterMolesProduced = 2f * limitingReactant; float waterLitersProduced = (waterMolesProduced * 18.01524f) / 1000f;  float methaneMolesProduced = limitingReactant; currentH2OProduced = myAirRS.randomFilter(waterLitersProduced); currentCH4Produced = myAirRS.randomFilter(methaneMolesProduced); } float distributedWaterLeft = myAirRS .getPotableWaterProducerDefinitionImpl().pushResourceToStore( currentH2OProduced); float distributedMethaneLeft = myAirRS .getMethaneProducerDefinitionImpl().pushResourceToStore( currentCH4Produced); }
if ((currentH2Consumed <= 0) || (currentCO2Consumed <= 0)) { currentH2OProduced = myAirRS.randomFilter(0f); currentCH4Produced = myAirRS.randomFilter(0f); myAirRS.getH2ProducerDefinitionImpl().pushResourceToStore( currentH2Consumed); myAirRS.getCO2ProducerDefinitionImpl().pushResourceToStore( currentCO2Consumed); } else {  float limitingReactant = Math.min(currentH2Consumed / 4f, currentCO2Consumed); if (limitingReactant == currentH2Consumed) myAirRS.getCO2ProducerDefinitionImpl().pushResourceToStore( currentCO2Consumed - limitingReactant); else myAirRS.getH2ProducerDefinitionImpl().pushResourceToStore( currentH2Consumed - 4f * limitingReactant); float waterMolesProduced = 2f * limitingReactant; float waterLitersProduced = (waterMolesProduced * 18.01524f) / 1000f;  float methaneMolesProduced = limitingReactant; currentH2OProduced = myAirRS.randomFilter(waterLitersProduced); currentCH4Produced = myAirRS.randomFilter(methaneMolesProduced); } myAirRS.getPotableWaterProducerDefinitionImpl().pushResourceToStore( currentH2OProduced); myAirRS.getMethaneProducerDefinitionImpl().pushResourceToStore( currentCH4Produced); }
    private void pushGasses() {        if ((currentH2Consumed <= 0) || (currentCO2Consumed <= 0)) {            currentH2OProduced = myAirRS.randomFilter(0f);            currentCH4Produced = myAirRS.randomFilter(0f);            myAirRS.getH2ProducerDefinitionImpl().pushResourceToStore(                    currentH2Consumed);            myAirRS.getCO2ProducerDefinitionImpl().pushResourceToStore(                    currentCO2Consumed);        } else {            // CO2 + 4H2 --> CH4 + 2H20            float limitingReactant = Math.min(currentH2Consumed / 4f,                    currentCO2Consumed);            if (limitingReactant == currentH2Consumed)                myAirRS.getCO2ProducerDefinitionImpl().pushResourceToStore(                        currentCO2Consumed - limitingReactant);            else                myAirRS.getH2ProducerDefinitionImpl().pushResourceToStore(                        currentH2Consumed - 4f * limitingReactant);            float waterMolesProduced = 2f * limitingReactant;            float waterLitersProduced = (waterMolesProduced * 18.01524f) / 1000f; //1000g/liter,            // 18.01524g/mole            float methaneMolesProduced = limitingReactant;            currentH2OProduced = myAirRS.randomFilter(waterLitersProduced);            currentCH4Produced = myAirRS.randomFilter(methaneMolesProduced);        }        float distributedWaterLeft = myAirRS                .getPotableWaterProducerDefinitionImpl().pushResourceToStore(                        currentH2OProduced);        float distributedMethaneLeft = myAirRS                        .getMethaneProducerDefinitionImpl().pushResourceToStore(                                currentCH4Produced);    }