首页 > 解决方案 > 化学反应功能中的不同限制供体

问题描述

我有几个相互关联的化学反应。每个反应都有 3 个可用的供体之一,这些供体正在被消耗,因此最终它们为 0,当这种情况发生时,反应无法执行。

因此,例如,如果供体 B 的浓度很小,并且在第一个反应中被消耗,则第三个反应无法执行。

#Reactions look like that. 
#1. A + B -> C +  B_1 
#2. C + G -> D + G_1
#3. D + B -> E + B_1
#4. E + G -> F + G_1
#5. D + H -> J + H_1

我通过excel阅读它们。

  wb = open_workbook(reactions)
  ws = wb.sheet_by_index(0)
  n_rows = ws.nrows

  #number of reactions
  no_reactions = n_rows - 1

 components = []
 for i in range(1,n_rows):
    if ws.cell_value(i,reactant_location) not in components:
       components.append(ws.cell_value(i,reactant_location))
    if ws.cell_value(i,product_location) not in components:
       components.append(ws.cell_value(i,product_location))
    if ws.cell_value(i,donor_location) not in components:
       components.append(ws.cell_value(i,donor_location))

 def simple_equation_system(t,c):
    for i in range(1,no_reactions+1):
       cr = components.index(ws.cell_value(i,reactant_location))
       cd = components.index(ws.cell_value(i,donor_location))
       cp = components.index(ws.cell_value(i,product_location)
       r_r = 1 * c[cr] * c[cd]
       dcdt[cr] += -r_r
       dcdt[cp] += r_r
     return dcdt

我不知道如何输入供体浓度,每次供体为“B”时,供体浓度减1。例如,如果B的浓度为1,则只能发生第一,第二,第五反应,但不是第三次和第四次。

也许我需要做一个遍历所有捐助者的 for 循环,当它找到它时,从前一个中减去。

标签: pythoncheminformatics

解决方案


推荐阅读