Пример #1
0
def setup_sulfatereduction(R, k_RTP=1):
    """ Set up a sulate reduction reaction to pass to the sulfate reducer
    as its metabolism. Use the reactor R."""

    # set up reagents. No need for composition as that is saved in the reactor.
    H2aq = reaction.reagent('H2(aq)', R.env, phase='aq')
    SO4 = reaction.reagent('SO4--', R.env, phase='aq', charge=-2)
    H = reaction.reagent('H+', R.env, phase='aq', charge=1)
    HS = reaction.reagent('HS-', R.env, phase='aq', charge=-1)
    H2O = reaction.reagent('H2O(l)', R.env, phase='l')

    # put reagents into a reaction. Dictionary values are the molar ratios.
    thermalSR = reaction.reaction({
        H2aq: 4,
        SO4: 1,
        H: 1
    }, {
        HS: 1,
        H2O: 4
    }, R.env)

    # not important for this code, but a rate constant is required
    # to set up an organism in NutMEG.
    thermalSR.rate_constant_RTP = k_RTP

    return thermalSR
Пример #2
0
    def initial_conditions(self, H2ppm, HSact=1e-10, setupcomp=True, addreaction=True):
        """ Set up a basic configuration, with pH 0 sulfuric acid
        droplet and dissolved H2.

        H2ppm : float
            H2 parts per million in the atmosphere around the droplet.
        HSact : float
            HS activity to use. Default is 1e-10
        setupcomp : bool
            Whether to set up the standard composition. Default True
        addreaction : bool
            Whether to include sulfate reduction in the reactionlist
        """

        if setupcomp:

            mol_H2 = VenusDrop.getgasconc('H2(aq)', self.env.P*H2ppm/(1e6),
              self.env.T, P_bar=self.env.P)
            mol_SO4 = 0.5 # assume fully dissoiated at pH 0 (from H2SO4)
            mol_H = 1.0 # pH zero
            mol_HS = HSact #? don't know, let's assume biogenic only.


            SO4 = reaction.reagent('SO4--', self.env, phase='aq', charge=-2,
              conc=mol_SO4, activity=mol_SO4)
            H2 = reaction.reagent('H2(aq)', self.env, phase='aq',
              conc=mol_H2, activity=mol_H2)

            H = reaction.reagent('H+', self.env, phase='aq', charge=1,
              conc=mol_H, activity=mol_H)
            HS = reaction.reagent('HS-', self.env, phase='aq', charge=-1,
              conc=HSact, activity=HSact)

            H2O = reaction.reagent('H2O(l)', self.env, phase='l', conc=55.5,
              phase_ss=True, activity=1)

            # add these reagents to the composition of the VenusDrop
            self.composition.update({H2.name:H2, SO4.name:SO4,
              H.name:H, H2O.name:H2O, HS.name:HS})


        self.pH = -math.log10((self.composition['H+'].activity))

        if addreaction:
            # put together an overall reaction fro sulfate reduction
            r = {self.composition['H2(aq)']:4, self.composition['SO4--']:1,
              self.composition['H+']:1}
            p = {self.composition['HS-']:1, self.composition['H2O(l)']:4}
            thermaloa = reaction.reaction(r,p,self.env)

            # add this reaction to the VenusDrop reactor.
            self.add_reaction(thermaloa, overwrite=True)
Пример #3
0
def setup_methanogenesis(R, k_RTP=1):
    """ Set up a methanogenesis reaction to pass to the methanogen
    as its metabolism. Use the reactor R."""

    # set up reagents. No need for composition as that is saved in the reactor.
    H2aq = reaction.reagent('H2(aq)', R.env, phase='aq')
    H2O = reaction.reagent('H2O(l)', R.env, phase='l')
    CO2 = reaction.reagent('CO2(aq)', R.env, phase='aq')
    CH4 = reaction.reagent('CH4(g)', R.env, phase='aq')

    # put reagents into a reaction. Dictionary values are the molar ratios.
    thermalSR = reaction.reaction({CO2: 1, H2aq: 4}, {CH4: 1, H2O: 2}, R.env)

    # not important for this code, but a rate constant is required
    # to set up an organism in NutMEG.
    thermalSR.rate_constant_RTP = k_RTP

    return thermalSR
Пример #4
0
    def extract_from_Reactions(self, ReactID, dbdict=None):
        """ Extract the data from the database and initialise a new reaction
        with its parameters.
        """

        # self.reaction_db_sqlparams(dbdict=dbdict)

        db = sqlite3.connect(self.dbpath)
        cursor = db.cursor()
        try:
            # extract all the data in alphabetical order by column names.
            # sloght fudge here because we only need the keys from
            # reaction_db_sqlparams
            tempdict = {'Type':['TEXT',0], 'equation':['TEXT',0],
              'reactants':['TEXT',0], 'products':['TEXT',0]}
            cursor.execute(sqlsc.SELECTcolumns('Reactions', tempdict, 'ReactID'), (ReactID,))
            Params = cursor.fetchone()
        except:
            raise
        finally:
            db.close()

        for k, nv in zip(sorted(tempdict.keys()), Params):
            tempdict[k] = [tempdict[k][0], nv]

        # now rebuild a reaction from this data
        # concentrations are zero for now, once in reactor they will be
        # unified with its composition.
        reactants, products = {}, {}
        if tempdict['Type'][1] == str(rxn.reaction):
            for k, v in ast.literal_eval(tempdict['reactants'][1]).items():
                temp_reagent = rxn.reagent(k, self.host.env,
                  phase=rxn.reagent.get_phase_str(k))
                reactants[temp_reagent] = v

            for k, v in ast.literal_eval(tempdict['products'][1]).items():
                temp_reagent = rxn.reagent(k, self.host.env,
                  phase=rxn.reagent.get_phase_str(k))
                products[temp_reagent] = v

            return rxn.reaction(reactants, products, self.host.env)
        else:
            raise IntegrityError('NutMEG is not set up to recover this ' + \
              'type of reaction from the database yet!')
    def setup_methanogenesis(self, R):
        """return a methanogenesis reaction object in reactor R"""

        CO2 = reaction.reagent('CO2(aq)', R.env, phase='aq')
        H2aq = reaction.reagent('H2(aq)', R.env, phase='aq')
        CH4aq = reaction.reagent('CH4(g)', R.env, phase='g')
        H2O = reaction.reagent('H2O(l)', R.env, phase='l')

        thermalMG = reaction.reaction({
            CO2: 1,
            H2aq: 4
        }, {
            CH4aq: 1,
            H2O: 2
        }, R.env)

        thermalMG.rate_constant_RTP = self.k_RTP
        # default is the one we calculated base on methanogens (LB3 pg 11)

        return thermalMG
def setup_sulfatereduction(R, k_RTP=0.0001):
    """Create a simple sulfate reduction reaction as a standard thermodynamic
    reaction inside reactor R.
    The reagents have no special properties, we can add those later
    """

    H2aq = reaction.reagent('H2(aq)', R.env, phase='aq')
    SO4 = reaction.reagent('SO4--', R.env, phase='aq', charge=-2)
    H = reaction.reagent('H+', R.env, phase='aq', charge=1)
    HS = reaction.reagent('HS-', R.env, phase='aq', charge=-1)
    H2O = reaction.reagent('H2O(l)', R.env, phase='l')

    # the overall reaction is 4H2 + SO4(2-) + H(+) -> HS(-) + 4H2O
    thermalSR = reaction.reaction({H2aq:4, SO4:1, H:1}, {HS:1, H2O:4},
      R.env)

    # we need to manually set the RTP rate constant for use in biochemistry
    thermalSR.rate_constant_RTP = k_RTP

    return thermalSR
def setup_methanogenesis(R, k_RTP=0.0001):
    """Create a simple methanogenesis reaction as a standard thermodynamic
    reaction inside reactor R.
    The reagents have no special properties, we can add those later
    """

    # introduce some reagents
    CO2 = reaction.reagent('CO2(aq)', R.env, phase='aq')
    H2aq = reaction.reagent('H2(aq)', R.env, phase='aq')
    CH4aq = reaction.reagent('CH4(g)', R.env, phase='g')
    H2O = reaction.reagent('H2O(l)', R.env, phase='l')

    # the overall reaction is CO2 + 4H2 -> CH4 + 2H2O
    thermalMG = reaction.reaction({CO2:1, H2aq:4}, {CH4aq:1, H2O:2},
      R.env)

    # we need to manually set the RTP rate constant for use in biochemistry
    thermalMG.rate_constant_RTP = k_RTP

    return thermalMG
Пример #8
0
    def build_ATP_reaction(self, celldata):
        """Create a reaction object describing the formation of ATP using
        cell parameters.

        celldata is in the form [activity ADP, activity P, activity ATP, pH]
        """
        ADP = rxn.reagent('+H3ADP1-(aq)',
                          self.locale.env,
                          activity=celldata[0],
                          phase='aq')
        P = rxn.reagent('H3PO4(aq)',
                        self.locale.env,
                        activity=celldata[1],
                        phase='aq')
        ATP = rxn.reagent('+H4ATP-(aq)',
                          self.locale.env,
                          activity=celldata[2],
                          phase='aq')
        #H = reaction.reagent('H+', self.env, activity=(10**-celldata[3]),
        #  phase='aq', molar_ratio=2.)
        H2O = rxn.reagent('H2O(l)',
                          self.locale.env,
                          phase='l',
                          conc=55.5,
                          phase_ss=True,
                          activity=1.0)

        self.ATP_production = rxn.reaction({
            ADP: 1,
            P: 1
        }, {
            ATP: 1,
            H2O: 1
        }, self.locale.env)
        self.ATP_production.rto_current_env()

        self.ATP_production.update_molar_gibbs_from_quotient(
            updatestdGibbs=False)
        self.G_P = self.ATP_production.molar_gibbs
    def initial_conditions(self,
                           R,
                           scale=1.0,
                           NH3conc=0.1,
                           H2Sconc=0.1,
                           setupcomp=True):
        """ set up the reactor by filling it with reagents and adding methanogeneis.

        scale : float
            scale by which to change the activity of CO2 and H2, if desired.
        NH3conc : float
            concentration of NH3 to put into the reactor
        H2Sconc : float
            concentration of H2S to put into the reactor.
        setupcomp : boolean
            True to set up the composition as well as the reaction. False
            to just add a methanogenesis reaction.
        """

        if setupcomp:
            mol_CO2 = self.params['mol_CO2'] * scale  #LB3 pg11
            mol_CH4 = self.params['mol_CH4']
            mol_H2 = self.params['mol_H2'] * scale
            Pconc = self.params['Pconc']

            mol_H = 10**(-R.pH)

            # reagents
            CO2 = reaction.reagent('CO2(aq)',
                                   R.env,
                                   phase='aq',
                                   conc=mol_CO2,
                                   activity=mol_CO2)
            H2aq = reaction.reagent('H2(aq)',
                                    R.env,
                                    phase='aq',
                                    conc=mol_H2,
                                    activity=mol_H2)
            CH4aq = reaction.reagent('CH4(g)',
                                     R.env,
                                     phase='g',
                                     conc=mol_CH4,
                                     activity=mol_CH4)
            H2O = reaction.reagent('H2O(l)',
                                   R.env,
                                   phase='l',
                                   conc=55.5,
                                   phase_ss=True)
            # el = reaction.reagent('e-', self.env, charge=-1)
            H = reaction.reagent('H+',
                                 R.env,
                                 charge=1,
                                 conc=mol_H,
                                 phase='aq',
                                 activity=mol_H)

            R.composition = {
                CO2.name: CO2,
                H2aq.name: H2aq,
                CH4aq.name: CH4aq,
                H2O.name: H2O,
                H.name: H
            }

            # add in CHNOPS, in elemental form for now
            # we already have C in the form of CO2 and CH4
            R.composition['NH3(aq)'] = reaction.reagent('NH3(aq)',
                                                        R.env,
                                                        phase='aq',
                                                        conc=NH3conc,
                                                        activity=NH3conc)
            # P and S we dont actually know, so let's arbitrarily say 1 micromole
            R.composition['P(aq)'] = reaction.reagent('P(aq)',
                                                      R.env,
                                                      phase='aq',
                                                      conc=Pconc,
                                                      activity=Pconc,
                                                      thermo=False)
            R.composition['H2S(aq)'] = reaction.reagent('H2S(aq)',
                                                        R.env,
                                                        phase='aq',
                                                        conc=H2Sconc,
                                                        activity=H2Sconc,
                                                        thermo=False)

        el = reaction.reagent('e-', R.env, charge=-1)
        # overall
        r = {R.composition['CO2(aq)']: 1, R.composition['H2(aq)']: 4}
        p = {R.composition['CH4(g)']: 1, R.composition['H2O(l)']: 2}
        thermaloa = reaction.reaction(r, p, R.env)

        R.add_reaction(thermaloa)
Пример #10
0
    def initial_conditions(self, pH, mol_CO2, Pconc, H2Oact=1.0, oceanvals=False, mol_CO2_oc=None):
        """
        Set up the initial conditions of the ocean in the configuration
        defined in the initialisation.

        Attributes
        ----------
        pH : float
            wider ocean (273 K) pH
        mol_CO2 : float
            Calculated activity of CO2 at this ocean location.
        Pconc : ufloat
            Concentration of phosphorus
        H2Oact : float, optional
            water activity, default 1.0.
        oceanvals : boolean, optional
            whether computing the wider ocean CO2 activity is needed.
        mol_CO2_oc : float, optional
            wider ocean CO2 activity. Default is None (then calculated here)
        """
        if mol_CO2_oc == None:
            mol_CO2_oc = mol_CO2
        if oceanvals:
            #get wider ocean CO_2
            mol_CO2_oc = Enceladus.get_CO2_from_HTHeating(T=273.15, pH=pH)[0]

        mol_CH4 = (self.mixingratios['CH4']/self.mixingratios['CO2'])*mol_CO2_oc#2.75*mol_CO2 #0.34*mol_CO2
        mol_H2 = (self.mixingratios['H2']/self.mixingratios['CO2'])*mol_CO2_oc#11*mol_CO2 #103*mol_CO2
        mol_NH3 = (self.mixingratios['NH3']/self.mixingratios['CO2'])*mol_CO2_oc
        mol_H2S = (self.mixingratios['H2S']/self.mixingratios['CO2'])*mol_CO2_oc
        # ^ from the ratios in the plumes, hence are upper limits
        mol_H=uf(10**(-pH),0)
        if self.nominals:
            mol_CH4 = mol_CH4.n
            mol_H2 = mol_H2.n
            mol_NH3 = mol_NH3.n
            mol_H2S = mol_H2S.n
            mol_H=uf(10**(-pH),0).n

        # reagents
        CO2 = reaction.reagent('CO2(aq)', self.env, phase='g', conc=mol_CO2,
          activity=mol_CO2)
        H2aq = reaction.reagent('H2(aq)', self.env, phase='aq', conc=mol_H2,
          activity=mol_H2)
        CH4aq = reaction.reagent('Methane(aq)', self.env, phase='g', conc=mol_CH4,
          activity=mol_CH4)
        H2O = reaction.reagent('H2O(l)', self.env, phase='l', conc=uf(55.5, 0), activity=uf(H2Oact,0))
        el = reaction.reagent('e-', self.env, charge=-1)
        H = reaction.reagent('H+', self.env, charge=1, conc=mol_H,
          phase='aq', activity=mol_H)

        self.composition = {CO2.name:CO2, H2aq.name:H2aq,
          CH4aq.name:CH4aq, H2O.name:H2O, H.name:H}

        # overall
        r = {self.composition['CO2(aq)']:1, self.composition['H2(aq)']:4}
        p = {self.composition['Methane(aq)']:1, self.composition['H2O(l)']:2}
        thermaloa = reaction.reaction(r,p,self.env)

        # redox
        fr = {self.composition['CO2(aq)']:1, self.composition['H+']:8, el:8}
        fp = {self.composition['Methane(aq)']:1, self.composition['H2O(l)']:2}
        fwd = reaction.redox_half(fr, fp, self.env, 8, -0.244)

        rr = {self.composition['H+']:8, el:8}
        rp = {self.composition['H2(aq)']:4}

        # E ref: Karp, Gerald, Cell and Molecular Biology, 5th Ed., Wiley, 2008
        rvs = reaction.redox_half(rr, rp, self.env, 8, -0.421)

        # redox cell reaction is thermal overall
        rx = reaction.redox(fwd, rvs, thermaloa, 8, self.env)

        self.reactionlist = {thermaloa.equation:{type(thermaloa):thermaloa,
          type(rx):rx}}

        # add in CHNOPS, in elemental form for now
        # we already have C in the form of CO2 and CH4
        self.composition['NH3(aq)'] = reaction.reagent('NH3(aq)', self.env, phase='aq', conc=mol_NH3,
          activity=mol_NH3) # from Glein, Baross, Waite 2015
        # P and S we don't actually know.
        self.composition['P(aq)'] = reaction.reagent('P(aq)', self.env, phase='aq', conc=Pconc,
          activity=Pconc, thermo=False)
        self.composition['H2S(aq)'] = reaction.reagent('H2S(aq)', self.env, phase='aq', conc=mol_H2S,
          activity=mol_H2S, thermo=False)
Пример #11
0
    def __init__(self,
                 host,
                 net_pathway,
                 n_ATP,
                 celldata=[0.0001, 0.004, 0.005, 7.],
                 name='pathway',
                 xi=1.0,
                 G_net_pathway=None,
                 pathwaytype=None,
                 *args,
                 **kwargs):
        """
        Parameters
        ----------
        celldata : list
            Concentration in the form [activity ADP, activity P, activity ATP, pH]
        G_net_pathway : NoneType or float
            If you want to pass the gibbs gree energy of the metabolic reaction
            use this, if not leave as None. Default ``None``.
        """
        self.host = host
        self.locale = host.locale
        self.name = name
        # unify the pathway with the local environment
        if type(net_pathway) is str:
            if pathwaytype == None:
                pathwaytype = type(rxn.reaction({}, {}, self.locale.env))
            self.net_pathway = self.locale.reactionlist[net_pathway][
                pathwaytype]
        elif type(net_pathway) is rxn.reaction or rxn.redox:
            # add reaction direct to the reactor, if it isn't there already
            self.locale.add_reaction(net_pathway,
                                     overwrite=kwargs.pop('overwrite', False))
            #set self.net_pathway now it has been unified
            self.net_pathway = self.locale.reactionlist[net_pathway.equation][
                type(net_pathway)]
        else:
            raise ValueError('Unable to process your reaction type')
        self.xi = xi
        if G_net_pathway is not None:
            self.G_A = G_net_pathway
        else:
            # get the molar gibbs from the net pathway reaction ourselves
            self.net_pathway.rto_current_env()
            self.net_pathway.update_molar_gibbs_from_quotient(
                updatestdGibbs=False)
            self.G_A = self.net_pathway.molar_gibbs

        self.build_ATP_reaction(celldata)  # also gets G_P

        if n_ATP is None:
            self.n_P = kwargs.pop('n_P', 0.0)
            self.n_HP = kwargs.pop('n_HP', 3.0)
            self.n_HR = kwargs.pop('n_HR', 0.0)
            self.n_ATP = (self.n_P + (self.n_HR / self.n_HP))
        else:
            self.n_ATP = n_ATP

        # self.k_RTP = kwargs.pop('k_RTP', 0.035/3600.)
        if self.net_pathway.rate_constant_RTP is None:
            self.net_pathway.rate_constant_RTP = kwargs.pop('k_RTP', 0.0001586)

        if not self.net_pathway.bool_rate_constants():
            raise ValueError('Rate constant unknown, we cannnot' + \
            'calucate respiration rates without them!')

        if self.net_pathway.rate_constant_env == None:
            #if we don't know the rate constant outside RTP,
            # it often changes by 2x every increase by 10 K.
            self.net_pathway.rate_constant_env = ( \
              self.net_pathway.rate_constant_RTP * \
              (2**((self.locale.env.T-298)/10)))

        #self.k_RTP = kwargs.pop('k_RTP', 0.065/60.)
        # self.k_T = self.k_RTP*math.exp(298.0/self.locale.env.T)

        # self.k_T = 34.7/3600#self.k_RTP*math.exp(6000*((1/298)-(1/self.locale.env.T)))
        # ^ get the rate const at this temperature
        # (only accurate for near RTP)

        self.G_C = self.n_ATP * self.G_P