Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok, I think i figured it out. The problem is, that i filled many lists with exact expressions and i exeeded the memmory available. Take the following lines from the loop:

c123.append(c123[i] - k1*step - k2*step)

After changing them all to something like:

c123.append(n(c123[i] - k1*step - k2*step))

everything works fine.

Thanks for tmonteil for your offering. If you want you can still take the code and have a look at your system memory. Maybe it would be good, if sage cloud tells if too much memory is used.

k1=2*10^(-4)
k1s=2*10^(-4)
k2=10^(-4)
k2s=10^(-4)
k3=5*10^(-5)
k4=10^(-4)
k5=5*10^(-5)

c123 = [2.5]
c13 = [0]
c1 = [0]
c12 = [0]
c2 = [0]
tList = [0]

#stepsize in seconds
step = 100
maxFound = False

for i in range(200):
    #beginnt mit 0 beechnungen fü nächsten zeitschitt
    t=step*i
    tList.append(t)

    #zwei geschwindigkeitsgesetze, beechnung fü n+1
    if c123[i] > 0.5 :
        c123.append(c123[i] - k1*step - k2*step)
        c13.append(c13[i] + k1*step - k3*step*c13[i])
        c12.append(c12[i] + k2*step - k4*step*c12[i] - k5*step*c12[i]^2)
    else:
        c123.append(c123[i] - k1s*step*c123[i] - k2*step*c123[i])
        c13.append(c13[i] + k1s*step*c123[i] - k3*step*c13[i])
        c12.append(c12[i] + k2s*step*c123[i] - k4*step*c12[i] - k5*step*c12[i]^2)
    #unabhängig von dem zeitpunkt
    c1.append(c1[i] + k3*step*c13[i] + k4*step*c12[i])
    c2.append(c2[i] + k5*step*c12[i]^2 )

    if (c13[i+1]<c13[i]) and (not maxFound):
        print "Maximum found for c13 found at", t, "s, bzw. ", n(t/3600), "h"
        print "Umsatz:", (c123[0]-c123[i])/c123[0]
        print "Selektivität 13:", (c13[i]-c13[0])/(c123[0]-c123[i])
        ausbeute13 = (c13[i]-c13[0])/c123[0]
        print "Ausbeute 13:", ausbeute13
        print "Selektivität 12:", (c12[i]-c12[0])/(c123[0]-c123[i])
        print "Selektivität 1:", (c1[i]-c1[0])/(c123[0]-c123[i])
        print "Selektivität 2:", (c2[i]-c2[0])/(c123[0]-c123[i])
        maxFound = True
    #pint t, "s"
    #pint c123[i], n(c13[i]), n(c1[i])
plotObject = list_plot(zip(tList,c123),plotjoined=True)
plotObject += list_plot(zip(tList,c13),plotjoined=True,color='red')
plotObject += list_plot(zip(tList,c12),plotjoined=True,color='green')
plotObject += list_plot(zip(tList,c1),plotjoined=True,color='orange')
plotObject += list_plot(zip(tList,c2),plotjoined=True,color='yellow')
plotObject.show()