Location: AE1-BG @ 326c38ed3757 / inverse03.py

Author:
nima <nafs080@aucklanduni.ac.nz>
Date:
2021-10-08 10:23:03+13:00
Desc:
Put the title for documentation
Permanent Source URI:
https://models.cellml.org/workspace/6b9/rawfile/326c38ed37572dad9be4b340da5f849cafa1437b/inverse03.py

# import pandas as pd
import numpy as np
import matplotlib.pyplot as plt



#
# A = np.array([[6, 1, 1],
#               [4, -2, 5],
#               [2, 8, 7]])
#
# A_inverse = np.linalg.inv(A)
# # print(A_inverse)




B = np.array([[1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0],
              [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
              [0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
              [0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0],
              [0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0],
              [0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0],
              [0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0],
              [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1],
              [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1],
              [0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0],
              [0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0],
              [0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0],
              [0,0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,0,1,-1,0,0,0,0]])

# [0,0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0]
# [0,0,0,0,0,0,0,0,0,0,1,-1,0,0,0,0]

BT = B.T


C = np.dot (BT,B)
# print(C.shape)

# print(C)


#forward and reverse kinetic rates from the original model
Y = np.log(np.array([[100],
                          [5000],
                          [562],
                          [61],
                          [5000],
                          [100],
                          [100],
                          [19800],
                          [135],
                          [1247],
                          [19800],
                          [100],
                          [1],
                          [1]]))
D = np.dot(BT,Y)
# print(D.shape)
sol = np.dot(np.linalg.pinv(C),D)
# print(sol.shape)
# print(sol)

# print(np.linalg.matrix_rank(C))
#
# # print(kinetic_rates)
# # #
# solution = kinetic_rates @ B_inv
# #
print("solution: ")
print(np.exp(sol))