Пример #1
0
    def execute(self):
        V = self.values["V"]
        A = self.values["A"]
        K = self.values["K"]
        c_in = self.values["c_in"]
        D = self.values["D"]
        L = self.values["L"]
        num_elements = self.values["num_elements"]
        maxt = self.values["maxt"]
        outputfreq = self.values["outputfreq"]

        time, uptake, c_in = dogbone(V, A, K, c_in, D, L, num_elements, maxt, outputfreq)
        return pd.DataFrame({"time": time, "uptake": uptake, "c_in": c_in})
def dogbone_SS(x,V,A,c_in,t_data,y_data):
    """
        Return the sum of square difference between
        model output and y_data for times t_data

        Args:
        x        a tuple containing K,D
        V        volume
        A        area
        c_in     initial concentration inside
        L        length
        t_data   time data points
        y_data   uptake data points
    """
    lnK,lnD,lnL = x
    K = np.exp(lnK)
    D = np.exp(lnD)
    L = np.exp(lnL)
    times, y_model, _ = dogbone(V,A,K,c_in,D,L,times_to_save=t_data)
    return np.sum((np.array(y_model)-np.array(y_data))**2)
Пример #3
0
V = 1000000.
A = 0.001

Bi  = 1e-12
L   = 1.
D   = 1e-5
c_L = 1.
c_inf = 0.

maxt = 100000
dt = 1000

num_elements = 200

times, numeric_uptake, _ = dogbone(V,A,1.,c_L,D,L,num_elements,maxt,dt)

x = np.linspace(0.,L,num_elements)

analytic_uptake = []
for t in times:
    analytic = Slab(Bi,L,D,c_L,c_inf)
    analytic_c = analytic.evaluate(x,t)
    analytic_uptake.append(np.trapz(analytic_c,x))

print A*np.array(analytic_uptake)
print numeric_uptake
plt.plot(times,A*np.array(analytic_uptake),'-')
plt.plot(times,np.array(numeric_uptake),'.')
plt.show()