In [1]:
import numpy as np
import os
from codeStore import support_fun as spf
import importlib

In [25]:
a = np.array([ 0.00482274, 0.00273938, 0.00237015, 0.00654226, -0.01258484, 0.00149229])
b = np.array([ 0.00252823, 0.00399812, 0.00172837, -0.00248533, 0.00733285, -0.05078458])
c = np.array([ 0.00373973, 0.00331423, 0.00202073, 0.0019905, -0.00260819, -0.02491045])
print(a - c)
print(b - c)
print(((a + b) / 2 - c) / c)


[ 0.00108301 -0.00057485  0.00034942  0.00455176 -0.00997665  0.02640274]
[-0.0012115   0.00068389 -0.00029236 -0.00447583  0.00994104 -0.02587413]
[-0.01717905  0.01645028  0.01411866  0.0190731   0.00682657 -0.01061021]

In [42]:
# case loop_table, each psi store in a independent folder. 
n_tail = 1
ph = 2/3
ecoli_name = 'ecoB03'

# sm = 'pf'
# ksp_max_it = 300
# main_fun_noIter = 0
# planeShearRatex = 1
# ecoli_velocity = 1
# ch = 3
# nth = 15
# rh1 = 0.3
# rh2 = 0.1
# job_dir = 'planeShearRatex_1a'
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 10, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 25

# sm = 'pf'
# ksp_max_it = 300
# main_fun_noIter = 0
# planeShearRatex = 1
# ecoli_velocity = 1
# ch = 0.1
# nth = 30
# rh1 = 0.03
# rh2 = 0.01
# ph = 0.2
# n_tail = 4
# ecoli_name = 'ecoB003'
# job_dir = 'planeShearRatex_1b'
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 10, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 25

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_1c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 1
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 50

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_2c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.5
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 50

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_4c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.25
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 50

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_0.5c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 2
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 50

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_0.25c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 4
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 50

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_1c_passive'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 50

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_1d'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 1
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 64
# n_norm_phi = 128

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_1d_passive'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 64
# n_norm_phi = 128

# sm = 'pf'
# ecoli_name = 'ecoB01_all'
# job_dir = 'planeShearRatex_-1c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = -1
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

sm = 'pf'
ecoli_name = 'ecoB05_all'
job_dir = 'ecoB05_tau1c'
ksp_max_it = 300
main_fun_noIter = 1
planeShearRatex = 1
ecoli_velocity = 4.019587915525599
ch = 3
nth = 20
rh1 = 0.5
rh2 = 0.15
ph = 10/3
n_tail = 1
importlib.reload(spf)
write_pbs_head = spf.write_pbs_head_newturb
norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
n_norm_theta = 32
n_norm_phi = 64

sm = 'pf'
ecoli_name = 'ecoB05_all'
job_dir = 'ecoB05_tau1c_passive'
ksp_max_it = 300
main_fun_noIter = 1
planeShearRatex = 1
ecoli_velocity = 0
ch = 3
nth = 20
rh1 = 0.5
rh2 = 0.15
ph = 10/3
n_tail = 1
importlib.reload(spf)
write_pbs_head = spf.write_pbs_head_newturb
norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
n_norm_theta = 32
n_norm_phi = 64

PWD = os.getcwd()
if not os.path.exists(job_dir):
    os.makedirs(job_dir)

t_name = os.path.join(job_dir, 'run.sh')
n_pbs = 0
with open(t_name, 'w') as frun:
    # create .pbs file
    frun.write('t_dir=$PWD \n')
    for norm_psi in norm_psi_list:
        job_name = '%s_psi%4.2f' % (ecoli_name, norm_psi)
        print(job_name)
        t_path = os.path.join(job_dir, job_name)
        if not os.path.exists(t_path):
            os.makedirs(t_path)
        t_name = os.path.join(t_path, '%s.pbs' % job_name)
        with open(t_name, 'w') as fpbs:
            write_pbs_head(fpbs, job_name)                           
            fpbs.write('mpirun -n 24 python ')
            fpbs.write(' ../../../loop_table_ecoli.py ')
            fpbs.write(' -f %s ' % job_name)
            fpbs.write(' -pickProblem %d ' % 0)
            fpbs.write(' -save_singleEcoli_vtk %d ' % 0)
            fpbs.write(' -rh1 %f ' % rh1)
            fpbs.write(' -rh2 %f ' % rh2)
            fpbs.write(' -ch %f ' % ch)
            fpbs.write(' -nth %d ' % nth)
            fpbs.write(' -eh %f ' % -1)
            fpbs.write(' -ph %f ' % ph)
            fpbs.write(' -hfct %f ' % 1)
            fpbs.write(' -n_tail %d ' % n_tail)
            fpbs.write(' -with_cover %d ' % 2)
            fpbs.write(' -left_hand %d ' % 0)
            fpbs.write(' -rs1 %f ' % 1.5)
            fpbs.write(' -rs2 %f ' % 0.5)
            fpbs.write(' -ds %f ' % 0.07)
            fpbs.write(' -es %f ' % -1)
            fpbs.write(' -with_T_geo %d ' % 0)
            fpbs.write(' -dist_hs %f ' % 0.5)
            fpbs.write(' -ksp_max_it %d ' % ksp_max_it)
            fpbs.write(' -plot_geo %d ' % 0)
            fpbs.write(' -rel_wsz %f ' % 0)
            fpbs.write(' -rel_whz %f ' % 100)
            fpbs.write(' -ffweight %f ' % 2)
            fpbs.write(' -sm %s ' % sm)
            fpbs.write(' -zoom_factor %f ' % 1)
            fpbs.write(' -planeShearRatex %f ' % planeShearRatex)
            fpbs.write(' -ecoli_velocity %f ' % ecoli_velocity)
            fpbs.write(' -n_norm_theta %d ' % n_norm_theta)
            fpbs.write(' -n_norm_phi %d ' % n_norm_phi)
            fpbs.write(' -norm_psi %f ' % norm_psi)
            fpbs.write(' -main_fun_noIter %d ' % main_fun_noIter)
            fpbs.write(' > %s.txt \n\n' % job_name)
        # write to .sh file
        frun.write('cd $t_dir/%s\n' % job_name)
        frun.write('qsub %s.pbs\n\n' % job_name)
        n_pbs = n_pbs + 1
    frun.write('\n')
    print('n_pbs = ', n_pbs)


ecoB05_all_psi0.00
ecoB05_all_psi0.42
ecoB05_all_psi0.84
ecoB05_all_psi1.26
ecoB05_all_psi1.68
ecoB05_all_psi2.09
ecoB05_all_psi2.51
ecoB05_all_psi2.93
ecoB05_all_psi3.35
ecoB05_all_psi3.77
ecoB05_all_psi4.19
ecoB05_all_psi4.61
ecoB05_all_psi5.03
ecoB05_all_psi5.45
ecoB05_all_psi5.86
n_pbs =  15

In [ ]:


In [3]:
rs1 = 1.5
rs2 = rs1 / 3
ds = 0.07
        
# sm = 'pf'
# ecoli_name = 'ecoC01_all'
# job_dir = 'ecoC01_tau1c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 1.6328647412856554
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01_all'
# job_dir = 'ecoC01_tau1c_passive'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC05_all'
# job_dir = 'ecoC05_tau1c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 1.524781932318225
# ch = 3
# nth = 20
# rh11 = 1.5
# rh12 = 0.5
# rh2 = 0.15
# ph = 10/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC05_all'
# job_dir = 'ecoC05_tau1c_passive'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0
# ch = 3
# nth = 20
# rh11 = 1.5
# rh12 = 0.5
# rh2 = 0.15
# ph = 10/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_tau1c_passive'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_tau1_wm0_b'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 16, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_tau1c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 1.6328647413699688
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

PWD = os.getcwd()
if not os.path.exists(job_dir):
    os.makedirs(job_dir)

t_name = os.path.join(job_dir, 'run.sh')
n_pbs = 0
with open(t_name, 'w') as frun:
    # create .pbs file
    frun.write('t_dir=$PWD \n')
    for norm_psi in norm_psi_list:
        job_name = '%s_psi%4.2f' % (ecoli_name, norm_psi)
        print(job_name)
        t_path = os.path.join(job_dir, job_name)
        if not os.path.exists(t_path):
            os.makedirs(t_path)
        t_name = os.path.join(t_path, '%s.pbs' % job_name)
        with open(t_name, 'w') as fpbs:
            write_pbs_head(fpbs, job_name)                           
            fpbs.write('mpirun -n 24 python ')
            fpbs.write(' ../../../loop_table_ecoli.py ')
            fpbs.write(' -f %s ' % job_name)
            fpbs.write(' -pickProblem %d ' % 0)
            fpbs.write(' -save_singleEcoli_vtk %d ' % 0)
            fpbs.write(' -rh11 %f ' % rh11)
            fpbs.write(' -rh12 %f ' % rh12)
            fpbs.write(' -rh2 %f ' % rh2)
            fpbs.write(' -ch %f ' % ch)
            fpbs.write(' -nth %d ' % nth)
            fpbs.write(' -eh %f ' % -1)
            fpbs.write(' -ph %f ' % ph)
            fpbs.write(' -hfct %f ' % 1)
            fpbs.write(' -n_tail %d ' % n_tail)
            fpbs.write(' -with_cover %d ' % 2)
            fpbs.write(' -left_hand %d ' % 0)
            fpbs.write(' -rs1 %f ' % rs1)
            fpbs.write(' -rs2 %f ' % rs2)
            fpbs.write(' -ds %f ' % ds)
            fpbs.write(' -es %f ' % -1)
            fpbs.write(' -with_T_geo %d ' % 0)
            fpbs.write(' -dist_hs %f ' % 0.5)
            fpbs.write(' -ksp_max_it %d ' % ksp_max_it)
            fpbs.write(' -plot_geo %d ' % 0)
            fpbs.write(' -rel_wsz %f ' % 0)
            fpbs.write(' -rel_whz %f ' % 100)
            fpbs.write(' -ffweight %f ' % 2)
            fpbs.write(' -sm %s ' % sm)
            fpbs.write(' -zoom_factor %f ' % 1)
            fpbs.write(' -planeShearRatex %f ' % planeShearRatex)
            fpbs.write(' -ecoli_velocity %f ' % ecoli_velocity)
            fpbs.write(' -n_norm_theta %d ' % n_norm_theta)
            fpbs.write(' -n_norm_phi %d ' % n_norm_phi)
            fpbs.write(' -norm_psi %f ' % norm_psi)
            fpbs.write(' -main_fun_noIter %d ' % main_fun_noIter)
            fpbs.write(' > %s.txt \n\n' % job_name)
        # write to .sh file
        frun.write('cd $t_dir/%s\n' % job_name)
        frun.write('qsub %s.pbs\n\n' % job_name)
        n_pbs = n_pbs + 1
    frun.write('\n')
    print('n_pbs =', n_pbs)


ecoC01B05_all_psi0.00
ecoC01B05_all_psi0.39
ecoC01B05_all_psi0.79
ecoC01B05_all_psi1.18
ecoC01B05_all_psi1.57
ecoC01B05_all_psi1.96
ecoC01B05_all_psi2.36
ecoC01B05_all_psi2.75
ecoC01B05_all_psi3.14
ecoC01B05_all_psi3.53
ecoC01B05_all_psi3.93
ecoC01B05_all_psi4.32
ecoC01B05_all_psi4.71
ecoC01B05_all_psi5.11
ecoC01B05_all_psi5.50
ecoC01B05_all_psi5.89
n_pbs = 16

In [86]:
1 / 676.00372212 * 193.66659815


Out[86]:
0.2864874730906016

In [33]:
1.524781932318225 / 1.5247819323031044


Out[33]:
1.0000000000099165

In [16]:
# case loop_table, each (psi1 and psi2) store in a independent folder. 
# swimmer with two tails in the ends. one is left hand and one is right hand. 
importlib.reload(spf)

sm = 'pf'
ecoli_name = 'ecoD01_all'
job_dir = 'dualTail_1c'
ksp_max_it = 300
main_fun_noIter = 1
planeShearRatex = 1
ch = 3
nth = 20
rh1 = 0.1
rh2 = 0.03
ph = 2/3
n_tail = 1
rel_tail1 = 193.66659814
rel_tail2 = 0
write_pbs_head = spf.write_pbs_head_newturb
norm_psi1_list = np.linspace(0, 2 * np.pi, 10, endpoint=False)
norm_psi2_list = np.linspace(0, 2 * np.pi, 10, endpoint=False)
n_norm_theta = 24
n_norm_phi = 48

PWD = os.getcwd()
if not os.path.exists(job_dir):
    os.makedirs(job_dir)

n_pbs = 0
for norm_psi1 in norm_psi1_list: 
    t_name = os.path.join(job_dir, 'run_psi1-%4.2f.sh' % norm_psi1)
    with open(t_name, 'w') as frun:
        # create .pbs file
        frun.write('t_dir=$PWD \n')
        for norm_psi2 in norm_psi2_list:
            job_name = '%s_psi1-%4.2f_psi2-%4.2f' % (ecoli_name, norm_psi1, norm_psi2)
#             print(norm_psi1, norm_psi2, job_name)
            t_path = os.path.join(job_dir, job_name)
            if not os.path.exists(t_path):
                os.makedirs(t_path)
            t_name = os.path.join(t_path, '%s.pbs' % job_name)
            with open(t_name, 'w') as fpbs:
                write_pbs_head(fpbs, job_name)                           
                fpbs.write('mpirun -n 24 python ')
                fpbs.write(' ../../../loop_table_dualTail_ecoli.py ')
                fpbs.write(' -f %s ' % job_name)
                fpbs.write(' -pickProblem %d ' % 0)
                fpbs.write(' -save_singleEcoli_vtk %d ' % 0)
                fpbs.write(' -rh1 %f ' % rh1)
                fpbs.write(' -rh2 %f ' % rh2)
                fpbs.write(' -ch %f ' % ch)
                fpbs.write(' -nth %d ' % nth)
                fpbs.write(' -eh %f ' % -1)
                fpbs.write(' -ph %f ' % ph)
                fpbs.write(' -hfct %f ' % 1)
                fpbs.write(' -n_tail %d ' % n_tail)
                fpbs.write(' -with_cover %d ' % 2)
                fpbs.write(' -left_hand %d ' % 0)
                fpbs.write(' -rs1 %f ' % 1.5)
                fpbs.write(' -rs2 %f ' % 0.5)
                fpbs.write(' -ds %f ' % 0.07)
                fpbs.write(' -es %f ' % -1)
                fpbs.write(' -with_T_geo %d ' % 0)
                fpbs.write(' -dist_hs %f ' % 0.5)
                fpbs.write(' -ksp_max_it %d ' % ksp_max_it)
                fpbs.write(' -plot_geo %d ' % 0)
                fpbs.write(' -rel_wsz %f ' % 0)
                fpbs.write(' -ffweight %f ' % 2)
                fpbs.write(' -sm %s ' % sm)
                fpbs.write(' -zoom_factor %f ' % 1)
                fpbs.write(' -planeShearRatex %f ' % planeShearRatex)
                fpbs.write(' -n_norm_theta %d ' % n_norm_theta)
                fpbs.write(' -n_norm_phi %d ' % n_norm_phi)
                fpbs.write(' -norm_psi1 %f ' % norm_psi1)
                fpbs.write(' -norm_psi2 %f ' % norm_psi2)
                fpbs.write(' -rel_tail1 %f ' % rel_tail1)
                fpbs.write(' -rel_tail2 %f ' % rel_tail2)
                fpbs.write(' -main_fun_noIter %d ' % main_fun_noIter)
                fpbs.write(' > %s.txt \n\n' % job_name)
            # write to .sh file
            frun.write('cd $t_dir/%s\n' % job_name)
            frun.write('qsub %s.pbs\n\n' % job_name)
            n_pbs = n_pbs + 1
        frun.write('\n')
print('n_pbs = ', n_pbs)


n_pbs =  100

In [ ]:


In [33]:
# case loop_table for helix only, each psi store in a independent folder. 
n_tail = 1
ph = 2/3
ecoli_name = 'hlxB03'
main_fun_noIter = 0

# sm = 'pf'
# ksp_max_it = 300
# planeShearRatex = 1
# ch = 3
# nth = 20
# rh1 = 0.3
# rh2 = 0.1
# ph = 0.666667
# n_tail = 1
# job_dir = ecoli_name + '_tau1a'
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 10, endpoint=False)
# n_norm_theta = 25
# n_norm_phi = 25

# sm = 'pf'
# ecoli_name = 'hlxB01'
# job_dir = ecoli_name + '_tau1a'
# ksp_max_it = 300
# main_fun_noIter = 0
# planeShearRatex = 1
# ch = 3
# nth = 20
# rh1 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# importlib.reload(spf)
# write_pbs_head = spf.write_pbs_head_newturb
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 64
# n_norm_phi = 64
# main_fun_noIter = 1

PWD = os.getcwd()
if not os.path.exists(job_dir):
    os.makedirs(job_dir)

t_name = os.path.join(job_dir, 'run.sh')
n_pbs = 0
with open(t_name, 'w') as frun:
    # create .pbs file
    frun.write('t_dir=$PWD \n')
    for norm_psi in norm_psi_list:
        job_name = '%s_psi%4.2f' % (ecoli_name, norm_psi)
        print(job_name)
        t_path = os.path.join(job_dir, job_name)
        if not os.path.exists(t_path):
            os.makedirs(t_path)
        t_name = os.path.join(t_path, '%s.pbs' % job_name)
        with open(t_name, 'w') as fpbs:
            write_pbs_head(fpbs, job_name)                           
            fpbs.write('mpirun -n 24 python ')
            fpbs.write(' ../../../loop_table_helix.py ')
            fpbs.write(' -f %s ' % job_name)
            fpbs.write(' -pickProblem %d ' % 0)
            fpbs.write(' -save_singleEcoli_vtk %d ' % 0)
            fpbs.write(' -rh1 %f ' % rh1)
            fpbs.write(' -rh2 %f ' % rh2)
            fpbs.write(' -ch %f ' % ch)
            fpbs.write(' -nth %d ' % nth)
            fpbs.write(' -eh %f ' % -1)
            fpbs.write(' -ph %f ' % ph)
            fpbs.write(' -hfct %f ' % 1)
            fpbs.write(' -n_tail %d ' % n_tail)
            fpbs.write(' -with_cover %d ' % 2)
            fpbs.write(' -left_hand %d ' % 0)
            fpbs.write(' -rs1 %f ' % 1.5)
            fpbs.write(' -rs2 %f ' % 0.5)
            fpbs.write(' -ds %f ' % 0.07)
            fpbs.write(' -es %f ' % -1)
            fpbs.write(' -with_T_geo %d ' % 0)
            fpbs.write(' -dist_hs %f ' % 0.5)
            fpbs.write(' -ksp_max_it %d ' % ksp_max_it)
            fpbs.write(' -plot_geo %d ' % 0)
            fpbs.write(' -rel_wsz %f ' % 0)
            fpbs.write(' -rel_whz %f ' % 100)
            fpbs.write(' -ffweight %f ' % 2)
            fpbs.write(' -sm %s ' % sm)
            fpbs.write(' -zoom_factor %f ' % 1)
            fpbs.write(' -planeShearRatex %f ' % planeShearRatex)
            fpbs.write(' -main_fun_noIter %d ' % main_fun_noIter)
            fpbs.write(' -n_norm_theta %d ' % n_norm_theta)
            fpbs.write(' -n_norm_phi %d ' % n_norm_phi)
            fpbs.write(' -norm_psi %f ' % norm_psi)
            fpbs.write(' > %s.txt \n\n' % job_name)
        # write to .sh file
        frun.write('cd $t_dir/%s\n' % job_name)
        frun.write('qsub %s.pbs\n\n' % job_name)
        n_pbs = n_pbs + 1
    frun.write('\n')
    print('n_pbs = ', n_pbs)


hlxB01_psi0.00
hlxB01_psi0.42
hlxB01_psi0.84
hlxB01_psi1.26
hlxB01_psi1.68
hlxB01_psi2.09
hlxB01_psi2.51
hlxB01_psi2.93
hlxB01_psi3.35
hlxB01_psi3.77
hlxB01_psi4.19
hlxB01_psi4.61
hlxB01_psi5.03
hlxB01_psi5.45
hlxB01_psi5.86
n_pbs =  15

In [ ]:


In [5]:
sm = 'pf'
ecoli_name = 'hlxC01'
job_dir = ecoli_name + '_tau1a'
ksp_max_it = 300
main_fun_noIter = 1
planeShearRatex = 1
ch = 3
nth = 20
rh11 = 0.3
rh12 = 0.1
rh2 = 0.03
ph = 2/3
n_tail = 1
importlib.reload(spf)
write_pbs_head = spf.write_pbs_head
norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
n_norm_theta = 32
n_norm_phi = 32
main_fun_noIter = 1

PWD = os.getcwd()
if not os.path.exists(job_dir):
    os.makedirs(job_dir)

t_name = os.path.join(job_dir, 'run.sh')
n_pbs = 0
with open(t_name, 'w') as frun:
    # create .pbs file
    frun.write('t_dir=$PWD \n')
    for norm_psi in norm_psi_list:
        job_name = '%s_psi%4.2f' % (ecoli_name, norm_psi)
        print(job_name)
        t_path = os.path.join(job_dir, job_name)
        if not os.path.exists(t_path):
            os.makedirs(t_path)
        t_name = os.path.join(t_path, '%s.pbs' % job_name)
        with open(t_name, 'w') as fpbs:
            write_pbs_head(fpbs, job_name)                           
            fpbs.write('mpirun -n 24 python ')
            fpbs.write(' ../../../loop_table_FatHelix.py ')
            fpbs.write(' -f %s ' % job_name)
            fpbs.write(' -pickProblem %d ' % 0)
            fpbs.write(' -save_singleEcoli_vtk %d ' % 0)
            fpbs.write(' -rh11 %f ' % rh11)
            fpbs.write(' -rh12 %f ' % rh12)
            fpbs.write(' -rh2 %f ' % rh2)
            fpbs.write(' -ch %f ' % ch)
            fpbs.write(' -nth %d ' % nth)
            fpbs.write(' -eh %f ' % -1)
            fpbs.write(' -ph %f ' % ph)
            fpbs.write(' -hfct %f ' % 1)
            fpbs.write(' -n_tail %d ' % n_tail)
            fpbs.write(' -with_cover %d ' % 2)
            fpbs.write(' -left_hand %d ' % 0)
            fpbs.write(' -rs1 %f ' % 1.5)
            fpbs.write(' -rs2 %f ' % 0.5)
            fpbs.write(' -ds %f ' % 0.07)
            fpbs.write(' -es %f ' % -1)
            fpbs.write(' -with_T_geo %d ' % 0)
            fpbs.write(' -dist_hs %f ' % 0.5)
            fpbs.write(' -ksp_max_it %d ' % ksp_max_it)
            fpbs.write(' -plot_geo %d ' % 0)
            fpbs.write(' -rel_wsz %f ' % 0)
            fpbs.write(' -rel_whz %f ' % 100)
            fpbs.write(' -ffweight %f ' % 2)
            fpbs.write(' -sm %s ' % sm)
            fpbs.write(' -zoom_factor %f ' % 1)
            fpbs.write(' -planeShearRatex %f ' % planeShearRatex)
            fpbs.write(' -main_fun_noIter %d ' % main_fun_noIter)
            fpbs.write(' -n_norm_theta %d ' % n_norm_theta)
            fpbs.write(' -n_norm_phi %d ' % n_norm_phi)
            fpbs.write(' -norm_psi %f ' % norm_psi)
            fpbs.write(' > %s.txt \n\n' % job_name)
        # write to .sh file
        frun.write('cd $t_dir/%s\n' % job_name)
        frun.write('qsub %s.pbs\n\n' % job_name)
        n_pbs = n_pbs + 1
    frun.write('\n')
    print('n_pbs = ', n_pbs)


hlxC01_psi0.00
hlxC01_psi0.42
hlxC01_psi0.84
hlxC01_psi1.26
hlxC01_psi1.68
hlxC01_psi2.09
hlxC01_psi2.51
hlxC01_psi2.93
hlxC01_psi3.35
hlxC01_psi3.77
hlxC01_psi4.19
hlxC01_psi4.61
hlxC01_psi5.03
hlxC01_psi5.45
hlxC01_psi5.86
n_pbs =  15

In [8]:
importlib.reload(spf)
planeShearRatey = 0
planeShearRatez = 0

# sm = 'pf'
# ecoli_name = 'ecoC01B03_all'
# job_dir = 'ecoC01B03_tau1c_passive'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 5
# rs2 = rs1 / 3
# ds = 0.07 / 5
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B03_all'
# job_dir = 'ecoC01B03_tau1c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.2864874730919643
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 5
# rs2 = rs1 / 3
# ds = 0.07 / 5
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B03_all'
# job_dir = 'ecoC01B03_T1'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.0014792842385756373
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 5
# rs2 = rs1 / 3
# ds = 0.07 / 5
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B01_all'
# job_dir = 'ecoC01B01_tau1c_passive'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 15
# rs2 = rs1 / 3
# ds = 0.07 / 15
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B01_all'
# job_dir = 'ecoC01B01_tau1c'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.019882410135194976
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 15
# rs2 = rs1 / 3
# ds = 0.07 / 15
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B01_all'
# job_dir = 'ecoC01B01_T1'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.00010266520127114365
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 15
# rs2 = rs1 / 3
# ds = 0.07 / 15
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B01_all'
# job_dir = 'ecoC01B01_T0.1'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.000010266520127114365
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 15
# rs2 = rs1 / 3
# ds = 0.07 / 15
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B01_all'
# job_dir = 'ecoC01B01_T0.01'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.0000010266520127114365
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 15
# rs2 = rs1 / 3
# ds = 0.07 / 15
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T193'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.8960497908782866
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T100'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.46267647567407155
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T50'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.23133823783703578
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T20'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.09253529513481432
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T10'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.04626764756740716
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T1'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.004626764756740716
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T2'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.009253529513481431
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T0.5'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.0023133823783703577
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T0.1'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.00046267647567407156
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T0.01'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.000046267647567407156
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T0.001'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.0000046267647567407156
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T0.25'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.001156691189185179
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B05_all'
# job_dir = 'ecoC01B05_T0.75'
# ksp_max_it = 300
# main_fun_noIter = 1
# planeShearRatex = 1
# ecoli_velocity = 0.003470073567555537
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

PWD = os.getcwd()
if not os.path.exists(job_dir):
    os.makedirs(job_dir)
n_case = 0
job_name_list = []
for norm_psi in norm_psi_list:
    job_name = '%s_psi%4.2f' % (ecoli_name, norm_psi)
    job_name_list.append(job_name)
    t_path = os.path.join(job_dir, job_name)
    if not os.path.exists(t_path):
        os.makedirs(t_path)
    t_name = os.path.join(t_path, '%s.sh' % job_name)
    print(t_name)
    with open(t_name, 'w') as fsh:
        fsh.write('mpirun -n 24 python ')
        fsh.write(' ../../../loop_table_ecoli.py ')
        fsh.write(' -f %s ' % job_name)
        fsh.write(' -pickProblem %d ' % 0)
        fsh.write(' -save_singleEcoli_vtk %d ' % 0)
        fsh.write(' -rh11 %f ' % rh11)
        fsh.write(' -rh12 %f ' % rh12)
        fsh.write(' -rh2 %f ' % rh2)
        fsh.write(' -ch %f ' % ch)
        fsh.write(' -nth %d ' % nth)
        fsh.write(' -eh %f ' % -1)
        fsh.write(' -ph %f ' % ph)
        fsh.write(' -hfct %f ' % 1)
        fsh.write(' -n_tail %d ' % n_tail)
        fsh.write(' -with_cover %d ' % 2)
        fsh.write(' -left_hand %d ' % 0)
        fsh.write(' -rs1 %f ' % rs1)
        fsh.write(' -rs2 %f ' % rs2)
        fsh.write(' -ds %f ' % ds)
        fsh.write(' -es %f ' % -1)
        fsh.write(' -with_T_geo %d ' % 0)
        fsh.write(' -dist_hs %f ' % 0.5)
        fsh.write(' -ksp_max_it %d ' % ksp_max_it)
        fsh.write(' -plot_geo %d ' % 0)
        fsh.write(' -rel_wsz %f ' % 0)
        fsh.write(' -rel_whz %f ' % 100)
        fsh.write(' -ffweight %f ' % 2)
        fsh.write(' -sm %s ' % sm)
        fsh.write(' -zoom_factor %f ' % 1)
        fsh.write(' -planeShearRatex %f ' % planeShearRatex)
        fsh.write(' -planeShearRatey %f ' % planeShearRatey)
        fsh.write(' -planeShearRatez %f ' % planeShearRatez)
        fsh.write(' -ecoli_velocity %e ' % ecoli_velocity)
        fsh.write(' -n_norm_theta %d ' % n_norm_theta)
        fsh.write(' -n_norm_phi %d ' % n_norm_phi)
        fsh.write(' -norm_psi %f ' % norm_psi)
        fsh.write(' -main_fun_noIter %d ' % main_fun_noIter)
        fsh.write(' > %s.txt \n\n' % job_name)
    n_case = n_case + 1
spf.write_main_run(write_pbs_head, job_dir, n_case)
spf.write_myscript(job_name_list, job_dir)


ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi0.00/ecoC01B05_all_psi0.00.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi0.39/ecoC01B05_all_psi0.39.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi0.79/ecoC01B05_all_psi0.79.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi1.18/ecoC01B05_all_psi1.18.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi1.57/ecoC01B05_all_psi1.57.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi1.96/ecoC01B05_all_psi1.96.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi2.36/ecoC01B05_all_psi2.36.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi2.75/ecoC01B05_all_psi2.75.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi3.14/ecoC01B05_all_psi3.14.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi3.53/ecoC01B05_all_psi3.53.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi3.93/ecoC01B05_all_psi3.93.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi4.32/ecoC01B05_all_psi4.32.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi4.71/ecoC01B05_all_psi4.71.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi5.11/ecoC01B05_all_psi5.11.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi5.50/ecoC01B05_all_psi5.50.sh
ecoC01B05_tau1_wm0_0z0/ecoC01B05_all_psi5.89/ecoC01B05_all_psi5.89.sh
ncase = 16
write parallel pbs file to ecoC01B05_tau1_wm0_0z0/main_run.pbs
write myscript csh file to ecoC01B05_tau1_wm0_0z0/myscript.csh
Out[8]:
True

In [17]:
# obtain the components of Eij, E is the symmetrical part of flow strain rate 
importlib.reload(spf)

sm = 'pf'
ecoli_name = 'ecoC01B05_all'
ecoli_velocity = 0
ch = 3
nth = 20
rh11 = 0.3
rh12 = 0.1
rh2 = 0.03
ph = 2/3
n_tail = 1
rs1 = 1.5 / 3
rs2 = rs1 / 3
ds = 0.07 / 3
importlib.reload(spf)
write_pbs_head = spf.write_pbs_head
norm_psi_list = np.linspace(0, 2 * np.pi, 16, endpoint=False)
n_norm_theta = 32
n_norm_phi = 64
ksp_max_it = 300
main_fun_noIter = 1


# job_dir = 'ecoC01B05_tau1_wm0_y00'
# planeShearRatex = 1
# planeShearRatey = 0
# planeShearRatez = 0
# planeShearNorm = 'y'

# job_dir = 'ecoC01B05_tau1_wm0_z00'
# planeShearRatex = 1
# planeShearRatey = 0
# planeShearRatez = 0
# planeShearNorm = 'z'

# job_dir = 'ecoC01B05_tau1_wm0_0x0'
# planeShearRatex = 0
# planeShearRatey = 1
# planeShearRatez = 0
# planeShearNorm = 'x'

# job_dir = 'ecoC01B05_tau1_wm0_0z0'
# planeShearRatex = 0
# planeShearRatey = 1
# planeShearRatez = 0
# planeShearNorm = 'z'

# job_dir = 'ecoC01B05_tau1_wm0_00x'
# planeShearRatex = 0
# planeShearRatey = 0
# planeShearRatez = 1
# planeShearNorm = 'x'

# job_dir = 'ecoC01B05_tau1_wm0_00y'
# planeShearRatex = 0
# planeShearRatey = 0
# planeShearRatez = 1
# planeShearNorm = 'y'

PWD = os.getcwd()
if not os.path.exists(job_dir):
    os.makedirs(job_dir)
n_case = 0
job_name_list = []
for norm_psi in norm_psi_list:
    job_name = '%s_psi%4.2f' % (ecoli_name, norm_psi)
    job_name_list.append(job_name)
    t_path = os.path.join(job_dir, job_name)
    if not os.path.exists(t_path):
        os.makedirs(t_path)
    t_name = os.path.join(t_path, '%s.sh' % job_name)
    print(t_name)
    with open(t_name, 'w') as fsh:
        fsh.write('mpirun -n 24 python ')
        fsh.write(' ../../../loop_table_ecoli.py ')
        fsh.write(' -f %s ' % job_name)
        fsh.write(' -pickProblem %d ' % 0)
        fsh.write(' -save_singleEcoli_vtk %d ' % 0)
        fsh.write(' -rh11 %f ' % rh11)
        fsh.write(' -rh12 %f ' % rh12)
        fsh.write(' -rh2 %f ' % rh2)
        fsh.write(' -ch %f ' % ch)
        fsh.write(' -nth %d ' % nth)
        fsh.write(' -eh %f ' % -1)
        fsh.write(' -ph %f ' % ph)
        fsh.write(' -hfct %f ' % 1)
        fsh.write(' -n_tail %d ' % n_tail)
        fsh.write(' -with_cover %d ' % 2)
        fsh.write(' -left_hand %d ' % 0)
        fsh.write(' -rs1 %f ' % rs1)
        fsh.write(' -rs2 %f ' % rs2)
        fsh.write(' -ds %f ' % ds)
        fsh.write(' -es %f ' % -1)
        fsh.write(' -with_T_geo %d ' % 0)
        fsh.write(' -dist_hs %f ' % 0.5)
        fsh.write(' -ksp_max_it %d ' % ksp_max_it)
        fsh.write(' -plot_geo %d ' % 0)
        fsh.write(' -rel_wsz %f ' % 0)
        fsh.write(' -rel_whz %f ' % 100)
        fsh.write(' -ffweight %f ' % 2)
        fsh.write(' -sm %s ' % sm)
        fsh.write(' -zoom_factor %f ' % 1)
        fsh.write(' -planeShearRatex %f ' % planeShearRatex)
        fsh.write(' -planeShearRatey %f ' % planeShearRatey)
        fsh.write(' -planeShearRatez %f ' % planeShearRatez)
        fsh.write(' -planeShearNorm %s ' % planeShearNorm)
        fsh.write(' -ecoli_velocity %e ' % ecoli_velocity)
        fsh.write(' -n_norm_theta %d ' % n_norm_theta)
        fsh.write(' -n_norm_phi %d ' % n_norm_phi)
        fsh.write(' -norm_psi %f ' % norm_psi)
        fsh.write(' -main_fun_noIter %d ' % main_fun_noIter)
        fsh.write(' > %s.txt \n\n' % job_name)
    n_case = n_case + 1
spf.write_main_run(write_pbs_head, job_dir, n_case)
spf.write_myscript(job_name_list, job_dir)


ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi0.00/ecoC01B05_all_psi0.00.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi0.39/ecoC01B05_all_psi0.39.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi0.79/ecoC01B05_all_psi0.79.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi1.18/ecoC01B05_all_psi1.18.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi1.57/ecoC01B05_all_psi1.57.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi1.96/ecoC01B05_all_psi1.96.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi2.36/ecoC01B05_all_psi2.36.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi2.75/ecoC01B05_all_psi2.75.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi3.14/ecoC01B05_all_psi3.14.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi3.53/ecoC01B05_all_psi3.53.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi3.93/ecoC01B05_all_psi3.93.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi4.32/ecoC01B05_all_psi4.32.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi4.71/ecoC01B05_all_psi4.71.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi5.11/ecoC01B05_all_psi5.11.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi5.50/ecoC01B05_all_psi5.50.sh
ecoC01B05_tau1_wm0_y00/ecoC01B05_all_psi5.89/ecoC01B05_all_psi5.89.sh
ncase = 16
write parallel pbs file to ecoC01B05_tau1_wm0_y00/main_run.pbs
write myscript csh file to ecoC01B05_tau1_wm0_y00/myscript.csh
Out[17]:
True

In [ ]:


In [24]:
# active helix with rotlet

# sm = 'pf'
# ecoli_name = 'ecoC01B00_all'
# job_dir = 'ecoC01B00_T1'
# ksp_max_it = 300
# planeShearRatex = 1
# ecoli_velocity = 0.03131296037255681
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B00_all'
# job_dir = 'ecoC01B00_T0.1'
# ksp_max_it = 300
# planeShearRatex = 1
# ecoli_velocity = 0.003131296037255681
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B00_all'
# job_dir = 'ecoC01B00_T0.01'
# ksp_max_it = 300
# planeShearRatex = 1
# ecoli_velocity = 0.0003131296037255681
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B00_all'
# job_dir = 'ecoC01B00_T0.001'
# ksp_max_it = 300
# planeShearRatex = 1
# ecoli_velocity = 0.00003131296037255681
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

sm = 'pf'
ecoli_name = 'ecoC01B00_all'
job_dir = 'ecoC01B00_T10'
ksp_max_it = 300
planeShearRatex = 1
ecoli_velocity = 0.03131296037255681 * 10
ch = 3
nth = 20
rh11 = 0.3
rh12 = 0.1
rh2 = 0.03
ph = 2/3
n_tail = 1
write_pbs_head = spf.write_pbs_head
norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
n_norm_theta = 32
n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B00_all'
# job_dir = 'ecoC01B00_T2'
# ksp_max_it = 300
# planeShearRatex = 1
# ecoli_velocity = 0.03131296037255681 * 2
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

# sm = 'pf'
# ecoli_name = 'ecoC01B00_all'
# job_dir = 'ecoC01B00_T0.5'
# ksp_max_it = 300
# planeShearRatex = 1
# ecoli_velocity = 0.03131296037255681 * 0.5
# ch = 3
# nth = 20
# rh11 = 0.3
# rh12 = 0.1
# rh2 = 0.03
# ph = 2/3
# n_tail = 1
# write_pbs_head = spf.write_pbs_head
# norm_psi_list = np.linspace(0, 2 * np.pi, 15, endpoint=False)
# n_norm_theta = 32
# n_norm_phi = 64

PWD = os.getcwd()
if not os.path.exists(job_dir):
    os.makedirs(job_dir)
n_case = 0
job_name_list = []
for norm_psi in norm_psi_list:
    job_name = '%s_psi%4.2f' % (ecoli_name, norm_psi)
    job_name_list.append(job_name)
    t_path = os.path.join(job_dir, job_name)
    if not os.path.exists(t_path):
        os.makedirs(t_path)
    t_name = os.path.join(t_path, '%s.sh' % job_name)
    print(t_name)
    with open(t_name, 'w') as fsh:
        fsh.write('mpirun -n 24 python ')
        fsh.write(' ../../../loop_table_ecoli.py ')
        fsh.write(' -f %s ' % job_name)
        fsh.write(' -pickProblem %d ' % 0)
        fsh.write(' -save_singleEcoli_vtk %d ' % 0)
        fsh.write(' -rh11 %f ' % rh11)
        fsh.write(' -rh12 %f ' % rh12)
        fsh.write(' -rh2 %f ' % rh2)
        fsh.write(' -ch %f ' % ch)
        fsh.write(' -nth %d ' % nth)
        fsh.write(' -eh %f ' % -1)
        fsh.write(' -ph %f ' % ph)
        fsh.write(' -hfct %f ' % 1)
        fsh.write(' -n_tail %d ' % n_tail)
        fsh.write(' -with_cover %d ' % 2)
        fsh.write(' -left_hand %d ' % 0)
        fsh.write(' -with_T_geo %d ' % 0)
        fsh.write(' -dist_hs %f ' % 0.5)
        fsh.write(' -ksp_max_it %d ' % ksp_max_it)
        fsh.write(' -plot_geo %d ' % 0)
        fsh.write(' -ffweight %f ' % 2)
        fsh.write(' -sm %s ' % sm)
        fsh.write(' -zoom_factor %f ' % 1)
        fsh.write(' -planeShearRatex %f ' % planeShearRatex)
        fsh.write(' -ecoli_velocity %f ' % ecoli_velocity)
        fsh.write(' -n_norm_theta %d ' % n_norm_theta)
        fsh.write(' -n_norm_phi %d ' % n_norm_phi)
        fsh.write(' -norm_psi %f ' % norm_psi)
        fsh.write(' -main_fun_rotlets %d ' % 1)
        fsh.write(' > %s.txt \n\n' % job_name)
    n_case = n_case + 1
spf.write_main_run(write_pbs_head, job_dir, n_case)
spf.write_myscript(job_name_list, job_dir)


ecoC01B00_T10/ecoC01B00_all_psi0.00/ecoC01B00_all_psi0.00.sh
ecoC01B00_T10/ecoC01B00_all_psi0.42/ecoC01B00_all_psi0.42.sh
ecoC01B00_T10/ecoC01B00_all_psi0.84/ecoC01B00_all_psi0.84.sh
ecoC01B00_T10/ecoC01B00_all_psi1.26/ecoC01B00_all_psi1.26.sh
ecoC01B00_T10/ecoC01B00_all_psi1.68/ecoC01B00_all_psi1.68.sh
ecoC01B00_T10/ecoC01B00_all_psi2.09/ecoC01B00_all_psi2.09.sh
ecoC01B00_T10/ecoC01B00_all_psi2.51/ecoC01B00_all_psi2.51.sh
ecoC01B00_T10/ecoC01B00_all_psi2.93/ecoC01B00_all_psi2.93.sh
ecoC01B00_T10/ecoC01B00_all_psi3.35/ecoC01B00_all_psi3.35.sh
ecoC01B00_T10/ecoC01B00_all_psi3.77/ecoC01B00_all_psi3.77.sh
ecoC01B00_T10/ecoC01B00_all_psi4.19/ecoC01B00_all_psi4.19.sh
ecoC01B00_T10/ecoC01B00_all_psi4.61/ecoC01B00_all_psi4.61.sh
ecoC01B00_T10/ecoC01B00_all_psi5.03/ecoC01B00_all_psi5.03.sh
ecoC01B00_T10/ecoC01B00_all_psi5.45/ecoC01B00_all_psi5.45.sh
ecoC01B00_T10/ecoC01B00_all_psi5.86/ecoC01B00_all_psi5.86.sh
ncase = 15
write parallel pbs file to ecoC01B00_T10/main_run.pbs
write myscript csh file to ecoC01B00_T10/myscript.csh
Out[24]:
True

GNU parallel version


In [ ]:
# archived. 

# PWD = os.getcwd()
# use_node = 3
# njob_node = 1
# n_job_pbs = use_node * njob_node
# random_order = True

# def comm_loop_table_ecoli(rh11, rh12, rh2, ph, ch, eh, nth, 
#                           hfct, n_tail, with_cover, left_hand, 
#                           rs1, rs2, ds, es, with_T_geo, dist_hs, ffweight, 
#                           planeShearRatex, planeShearRatey, ecoli_velocity, 
#                           zoom_factor, n_norm_theta, n_norm_phi, norm_psi, 
#                           pickProblem, save_singleEcoli_vtk, plot_geo, 
#                           sm, ksp_max_it, main_fun_noIter, f):

#     ts = 'mpirun -np 24 python ../../loop_table_ecoli.py '
#     ts = ts + ' -rh11 %f -rh12 %f -rh2 %f -ph %f -ch %f -eh %f -nth %d ' % (rh11, rh12, rh2, ph, ch, eh, nth)
#     ts = ts + ' -hfct %f -n_tail %d -with_cover %d -left_hand %d ' % (hfct, n_tail, with_cover, left_hand)
#     ts = ts + ' -planeShearRatex %f -planeShearRatey %f -ecoli_velocity %f ' % (planeShearRatex, planeShearRatey, ecoli_velocity)
#     ts = ts + ' -zoom_factor %f -n_norm_theta %d -n_norm_phi %d -norm_psi %f ' % (zoom_factor, n_norm_theta, n_norm_phi, norm_psi)
#     ts = ts + ' -pickProblem %d -save_singleEcoli_vtk %d -plot_geo %d ' % (pickProblem, save_singleEcoli_vtk, ksp_max_it, plot_geo)
#     ts = ts + ' -sm %s -ksp_max_it %d -main_fun_noIter %d -f %s ' % (sm, ksp_max_it, main_fun_noIter, f)
#     return ts
    
# rh11, rh12, rh2, ph, ch, eh, nth = 0.3, 0.1, 0.03, 2/3, 3, -1, 20
# hfct, n_tail, with_cover, left_hand = 1, 1, 2, 0
# rs1 = 1.5 / 3
# rs2 = rs1 / 3
# ds = 0.07 / 3
# es, with_T_geo, dist_hs, ffweight = -1, 0, 0.5, 2
# planeShearRatex, planeShearRatey, ecoli_velocity = 0, 1, 0
# zoom_factor, n_norm_theta, n_norm_phi, n_norm_psi = 1, 32, 64, 16
# pickProblem, save_singleEcoli_vtk, plot_geo = 0, 0, 0
# sm, ksp_max_it, main_fun_noIter = 'pf', 300, 1
# norm_psi_list = np.linspace(0, 2 * np.pi, n_norm_psi, endpoint=False)

# ########################################################################################################
# t_path = os.path.join(PWD, job_dir)
# if not os.path.exists(t_path):
#     os.makedirs(t_path)
# # generate all comment file. 
# ch_list, ph_list = np.meshgrid(ch_list, ph_list)
# comm_list = []
# txt_list = []
# for i0, norm_psi in norm_psi_list:
#     f = 'tail_ch%.2f_ph%.2f_n%d' % (chi, phi, n_tail)
#     n_segment = n_segment_fct * chi
#     ts = comm_do_slb(rh1, rh2, n_segment, phi, chi, n_tail, 
#                      slb_geo_fun, 
#                      sm, slb_epsabs, slb_epsrel, slb_limit, f)
#     comm_list.append(ts)
#     txt_list.append(f)
# spf.write_main_run_comm_list(comm_list, txt_list, use_node, njob_node, job_dir, 
#                              write_pbs_head, n_job_pbs, random_order=random_order)