예제 #1
0
    def build_tanks_in_series(self):
        # Setting up the biox reactor
        self.upstream = reactors.BaseUpStream(ferric=self.ferric,
                                              ferrous=self.ferrous,
                                              ratio=self.ferric_ferrous)
        self.biox_rate = reactions.BioxidationRate(
            initial_cells=self.initial_cells)
        self.biox_cstr = self.create_reactor(reactors.CSTR, self.biox_volume,
                                             self.upstream)
        self.biox_cstr.create_components(self.biox_rate)

        self.system_components.append(self.biox_rate.reactant_name)

        # Setting up the Chemical Reactor
        # self.copper_rate = reactions.MetalDissolutionRate(
        #                                     constants.COPPER,
        #                                     self.initial_copper,
        #                                     system=constants.CONTINUOUS)
        self.chem_cstr = self.create_reactor(reactors.CSTR, self.chem_volume,
                                             self.biox_cstr)
        self.add_reactants_to_chem_cstr()
        # self.chem_cstr.create_components(self.copper_rate)
        # That the system can be aware of all ions/ reactants
        # self.system_components.append(self.copper_rate.reactant_name)

        self.add_system_ions_to_reactors()
        self.img = "/static/img/system/tanks_in_series.png"
        self.system_type = "Tanks in Series"
예제 #2
0
    def build_cyclic_tanks(self):

        # This is temporary as once the chemical reactor is built,
        # the upstream will be updated
        upstream = reactors.BaseUpStream(ferric=self.ferric,
                                         ferrous=self.ferrous,
                                         ratio=self.ferric_ferrous)

        # Building the Bioxidation Reactor
        self.biox_rate = reactions.BioxidationRate(
            initial_cells=self.initial_cells)
        self.biox_cstr = self.create_reactor(reactors.CSTR, self.biox_volume,
                                             upstream)
        self.biox_cstr.create_components(self.biox_rate)
        self.system_components.append(self.biox_rate.reactant_name)

        # Setting up the Chemical Reactor
        # self.copper_rate = reactions.MetalDissolutionRate(
        #                                     constants.COPPER,
        #                                     self.initial_copper,
        #                                     system=constants.CONTINUOUS)
        self.chem_cstr = self.create_reactor(reactors.CSTR, self.chem_volume,
                                             self.biox_cstr)
        # self.chem_cstr.create_components(self.copper_rate)
        # self.system_components.append(self.copper_rate.reactant_name)
        self.add_reactants_to_chem_cstr()

        # Updating the biox_cstr upstream
        self.biox_cstr.upstream = self.chem_cstr
        self.biox_cstr.update_flow_in()

        self.add_system_ions_to_reactors()
        self.img = "/static/img/system/closed_loop.png"
        self.system_type = "Closed Cyclic Tanks"
예제 #3
0
    def test_running_cstr_reactor_with_simplified_hansford(self):
        upstream = reactors.BaseUpStream()
        cstr = reactors.CSTR(self.volume, upstream)

        biox_rate = reactions.BioxidationRate(self.ferric_conc)

        cstr.create_components(biox_rate)
        self.assertIn(biox_rate, cstr.components)

        self.assertEqual(cstr.flow_in, upstream.flow_out)
        self.assertEqual(cstr.flow_in, cstr.flow_out)
        self.assertIsNotNone(cstr.flow_in)

        # self.assertEqual(cstr.ions[biox_rate.reactant_name], 0)

        output = cstr.run()

        self.assertIn('total_rate_ferric', output["cstr_data"])
        self.assertIn('total_rate_ferrous', output["cstr_data"])
        self.assertEqual(output["cstr_data"]['total_rate_ferrous'],
                         -output["cstr_data"]['total_rate_ferric'])

        self.assertEqual(
            output["cstr_data"]['total_rate_ferrous'], output["cstr_data"]
            ["components"][biox_rate.reactant_name]["rate_ferrous"])
        self.assertNotEqual(output["flow_out"]["components"]["ferric"],
                            upstream.flow_out["components"]["ferric"])

        self.assertEqual(output["flow_out"]["components"]["ferric"],
                         cstr.flow_out["components"]["ferric"])

        # Assert that the change in ferric is equal to change in rate
        self.assertAlmostEqual(
            output["flow_out"]["components"]["ferric"] -
            cstr.flow_in["components"]["ferric"], output["cstr_data"]
            ['total_rate_ferric'])  # Almost equal due to floating point errors
예제 #4
0
def run_bioxidation_raction_rates_simulation():
    biox_reaction = reactions.BioxidationRate(0, 0)
    data = []

    RANGE = 1000
    for i in range(RANGE):
        temp = {}

        ferric = (i * 1.0 / RANGE)
        ferrous = (1 - (i * 1.0 / RANGE))

        biox_reaction.update_global_reactant_concentrations(ferric, ferrous)

        if not ferric == 0:  # Avoid division by zero error
            np.seterr(divide='ignore')
            # rate_ferrous, rate_ferric, component_conc = biox_reaction.run()
            output = biox_reaction.run()

            ferric_ferrous = np.divide(ferric, ferrous)

            temp = {"ferric_ferrous": ferric_ferrous, "step": i}
            temp.update(output)
            data.append(temp)
    return data
예제 #5
0
    def test_biox_reaction_rate(self):
        ferrous_conc = 0.01
        ferric_conc = 10

        biox = reactions.BioxidationRate(ferric_conc, ferrous_conc)
        biox.simplified_hansford()