<jupyter_start><jupyter_text>Force-velocity relation<jupyter_code>params = deepcopy(default_params_gen)
params[0] = 0
s2 = 0
s1 = np.linspace(-1, 1, 200).tolist()
vel = [vel_force(s, s2, params) for s in s1]
force = np.array([para_force21(s, s2, params) for s in s1])
fig, ax = plt.subplots(figsize=(10,7))
lin_vel = np.piecewise(force, 
                         [force <-1., (force >= -1) & (force < 0), force >= 0], 
                         [0, lambda force: params[11]*(1.+force/params[9]), 1])
ax.plot(force, lin_vel, label="Linear")
ax.plot(force, vel, label="Smoothed")
ax.axvline(x=0, color='r', linestyle='--', label="Zero force")
ax.set_xlabel("Normalized parallel force ($F_{\parallel}/F_s$)")
ax.set_ylabel("Normalized motor velocity ($v_g/v_o$)")
ax.set_ylim(0, 1.2)
ax.legend()
plt.show()<jupyter_output><empty_output><jupyter_text>Spring constant compare<jupyter_code>fs = 2.0
ks = .3
ho = 52.
sep = 25.
def get_zrl_parallel_spring_const(ks, fs, ho, sep):
    a = sep*sep
    b = (ks*ks*(ho*ho - sep*sep)) + (fs*fs)
    c = -ks*ks*fs*fs
    
    ks_new = np.sqrt((-1.*b + np.sqrt((b*b)-(4.*a*c)))/(2.*a)) 
    return ks_new
def get_zrl_spring_const(ks, fs, ho, sep):
    return ks*fs/(fs+(ho*ks))
def get_nzrl_parallel_force(x, ks, ho, sep):
    return -1.*ks*x*(1.-(ho/np.sqrt(x*x + sep*sep)))
def get_nzrl_force(h, ks, ho):
    return -1.*ks*(h-ho)
#print(ks)
ks_new1 = 0.03715512882326001
ks_new2 = get_zrl_spring_const(ks, fs, ho, sep)
#print("Matching distance along filament for parallel:", fs/ks_new1)
#print("Matching distance for parallel:", np.sqrt((fs/ks_new1)**2+sep**2))
#print(get_zrl_parallel_force(fs/ks_new1, ks, ho, sep))

x = np.linspace(0,1.5*fs/ks_new1, 50)

fig, axarr = plt.subplots(2,2,figsize=(10,10))
axarr[0,0].plot(x, -ks_new1*x, label='rest length = 0 nm')
axarr[0,0].plot(x, get_nzrl_parallel_force(x,ks,ho,sep), label="rest length = {} nm".format(ho))
axarr[0,0].axhline(y=-fs, color='r', linestyle='--', label="Stall force")
axarr[0,0].set_xlabel('Distance along filament (nm)')
axarr[0,0].set_ylabel('Force parallel to filament(pN)')
axarr[0,0].set_title('Parallel force calculation\n(Parallel force match)')
axarr[0,0].legend()

axarr[0,1].plot(x, -ks_new1*x, label='rest length = 0 nm')
axarr[0,1].plot(x, get_nzrl_force(x,ks,ho), label="rest length = {} nm".format(ho))
axarr[0,1].axhline(y=-fs, color='r', linestyle='--', label="Stall force")
axarr[0,1].set_xlabel('Protein stretch(nm)')
axarr[0,1].set_ylabel('Force (pN)')
axarr[0,1].set_title('Total force calculation\n(Parallel force match)')
axarr[0,1].set_xlim(0,1.5*fs/ks_new1)
axarr[0,1].legend()
#axarr[0].set_ylim(-5, 0)


print(ks_new2)
#print("Matching distance along filament for parallel:", np.sqrt((fs/ks_new1)**2 - sep**2))
#print("Matching distance for general:", fs/ks_new2)
#print(get_zrl_parallel_force(fs/ks_new1, ks, ho, sep))
axarr[1,0].plot(x, -ks_new2*x, label='rest length = 0 nm')
axarr[1,0].plot(x, get_nzrl_parallel_force(x,ks,ho,sep), label="rest length = {} nm".format(ho))
axarr[1,0].axhline(y=-fs, color='r', linestyle='--', label="Stall force")
axarr[1,0].set_xlabel('Distance along filament (nm)')
axarr[1,0].set_ylabel('Force parallel to filament(pN)')
axarr[1,0].set_title('Parallel force calculation\n(Total force match)')
axarr[1,0].legend()
axarr[1,1].plot(x, -ks_new2*x, label='rest length = 0 nm')
axarr[1,1].plot(x, get_nzrl_force(x,ks,ho), label="rest length = {} nm".format(ho))
axarr[1,1].axhline(y=-fs, color='r', linestyle='--', label="Stall force")
axarr[1,1].set_xlabel('Protein stretch(nm)')
axarr[1,1].set_ylabel('Force (pN)')
axarr[1,1].set_title('Total force calculation\n(Total force match)')
axarr[1,1].set_xlim(0,1.5*fs/ks_new1)
axarr[1,1].legend()
#axarr[1].set_ylim(-5, 0)
plt.tight_layout()
#print(ks)
ks_new1 = 0.03715512882326001
ks_new2 = get_zrl_spring_const(ks, fs, ho, sep)
#print("Matching distance along filament for parallel:", fs/ks_new1)
#print("Matching distance for parallel:", np.sqrt((fs/ks_new1)**2+sep**2))
#print(get_zrl_parallel_force(fs/ks_new1, ks, ho, sep))

x = np.linspace(0,1.5*fs/ks_new1, 50)

fig, axarr = plt.subplots(1,2,figsize=(10,5))
#axarr[0,0].plot(x, -ks_new1*x)
#axarr[0,0].plot(x, get_nzrl_parallel_force(x,ks,ho,sep))
#axarr[0,0].axhline(y=-fs, color='r', linestyle='--', label="Stall force")
#axarr[0,0].set_xlabel('Distance along filament (nm)')
#axarr[0,0].set_ylabel('Force parallel to filament(pN)')
#axarr[0,0].set_title('Parallel force calculation')
#axarr[0,1].plot(x, -ks_new1*x)
#axarr[0,1].plot(x, get_nzrl_force(x,ks,ho,sep))
#axarr[0,1].axhline(y=-fs, color='r', linestyle='--', label="Parallel force")
#axarr[0,1].set_xlabel('Protein stretch(nm)')
#axarr[0,1].set_ylabel('Force (pN)')
#axarr[0,1].set_title('Total force calculation')
#axarr[0,1].set_xlim(0,1.5*fs/ks_new1)
#axarr[0].set_ylim(-5, 0)


print(ks_new2)
#print("Matching distance along filament for parallel:", np.sqrt((fs/ks_new1)**2 - sep**2))
#print("Matching distance for general:", fs/ks_new2)
#print(get_zrl_parallel_force(fs/ks_new1, ks, ho, sep))
axarr[1,0].plot(x, -ks_new2*x)
axarr[1,0].plot(x, get_nzrl_parallel_force(x,ks,ho,sep))
axarr[1,0].axhline(y=-fs, color='r', linestyle='--', label="Parallel force")
axarr[1,0].set_xlabel('Distance along filament (nm)')
axarr[1,0].set_ylabel('Force parallel to filament(pN)')
axarr[1,0].set_title('Parallel force calculation')
axarr[1,1].plot(x, -ks_new2*x)
axarr[1,1].plot(x, get_nzrl_force(x,ks,ho,sep))
axarr[1,1].axhline(y=-fs, color='r', linestyle='--', label="Parallel force")
axarr[1,1].set_xlabel('Protein stretch(nm)')
axarr[1,1].set_ylabel('Force (pN)')
axarr[1,1].set_title('Total force calculation')
axarr[1,1].set_xlim(0,1.5*fs/ks_new1)
#axarr[1].set_ylim(-5, 0)
plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Solutions to steady state<jupyter_code>phi = Function('phi')
s1_arr = np.asarray([3,5,8])
s2_arr = np.asarray([4,12,15])
print(s1_arr)
print(s2_arr)
Y,X = np.meshgrid(s2_arr, s1_arr)
print(X)
print(Y)
c = np.sqrt(np.power(X,2)+np.power(Y,2))

import time
a = np.linspace(0,1,1000)
b = np.linspace(1,2,1000)
X, Y = np.meshgrid(a,b)
t0 = time.time()
c = np.sqrt(np.power(X,2)+np.power(Y,2))
t1 = time.time()
print("Total time: ", t1-t0)
t0 = time.time()
c = np.exp(np.power(np.sqrt(np.power(X,2)+np.power(Y,2))-.1,2))
t1 = time.time()
print("Total time: ", t1-t0)
print(c)
d = np.asarray([1,2,3])
e = np.outer(d,c)
print(e.shape)
s1 = np.arange(5)
s2 = np.arange(5,9)
print(s1, s2)
u1=np.asarray([1,0,0])
u2=np.asarray([0,1,0])
S2, S1 = np.meshgrid(s2,s1)
hvec = S2[:,:,None]*u2[None,None,:]-S1[:,:,None]*u1[None,None,:]
print(hvec)
A = np.linalg.norm(hvec, axis=2)
print(A)
B = np.ones((5,4,3))
B[:,:,1]*=2
B[:,:,2]*=3
print(B)
C = A[:,:,None]*B[:,:,:]
print(C)
print(C.sum(axis=(0,1)))
v = np.asarray([[1,0,0],[0,1,0],[0,0,1],[1,0,0]])
print(v)
D = np.cross(v,C)
print(D)
u = np.asarray([1,2,3])
uu = np.outer(u,u)
print(uu)
np.power(uu,2)
Iish = np.eye(3)
print(Iish)<jupyter_output>[[ 1.  0.  0.]
 [ 0.  1.  0.]
 [ 0.  0.  1.]]<jupyter_text>Source testing<jupyter_code>cmap = mpl.cm.ScalarMappable( mpl.colors.Normalize(0, 50), 'viridis')
fig, ax = plt.subplots()
print(cmap.to_rgba(25))
#ax.plot(np.linspace(0,10), np.linspace(0,10)*10)
fig.colorbar(cmap, ax=ax)

mat = np.ones((200,200))
#mat = np.arange(81).reshape(9,9)
print(mat)
#mat_new = mat.reshape(3,3,3,3)
mat_new = mat.reshape(20,10,20,10)
print(mat_new)
mat_coarse = mat_new.sum(axis=(1,3))
print(mat_coarse)
print(mat_coarse.shape)<jupyter_output>[[1. 1. 1. ... 1. 1. 1.]
 [1. 1. 1. ... 1. 1. 1.]
 [1. 1. 1. ... 1. 1. 1.]
 ...
 [1. 1. 1. ... 1. 1. 1.]
 [1. 1. 1. ... 1. 1. 1.]
 [1. 1. 1. ... 1. 1. 1.]]
[[[[1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   ...
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]]

  [[1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   ...
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]]

  [[1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   ...
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]]

  ...

  [[1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   ...
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]]

  [[1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   ...
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1. ... 1. 1. 1.]
   [1. 1. 1[...]
{'fraction_non_alphanumeric': 0.24949911608721273, 'fraction_numerical': 0.0750736593989393, 'mean_word_length': 3.991764705882353, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '509450', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 4331, 'n_tokens_neox': 4023, 'n_words': 750, 'path': 'notebooks/fokker_planck_misc.ipynb', 'repo_name': 'lamsoa729/FoXlink', 'size': '8485'}