restart conflict with preminim
authorCezary Czaplewski <czarek@chem.univ.gda.pl>
Mon, 16 Apr 2018 15:08:54 +0000 (17:08 +0200)
committerCezary Czaplewski <czarek@chem.univ.gda.pl>
Mon, 16 Apr 2018 15:08:54 +0000 (17:08 +0200)
django_simple/todo/jobfiles.py
django_simple/todo/views.py

index 61d2c45..6311e07 100644 (file)
@@ -147,7 +147,7 @@ CUTOFF=7.00000 WCORR4=0.00000"""
           if instance.md_pdbref:
              control_line = control_line+'pdbref '
             
-          type_line = 'restart reset_vel=0'\
+          type_line = '        reset_vel=0'\
              +' t_bath='+str(instance.md_temp)\
              +' nstep='+str(instance.md_nstep)\
              +' ntwe='+str(instance.md_ntwe)\
@@ -187,7 +187,7 @@ CUTOFF=7.00000 WCORR4=0.00000"""
              cntrl_saxs=' nsaxs='+str(nsaxs)+' scal_rad='+str(instance.scal_rad) 
              control_line += cntrl_saxs             
             
-          type_line = 'restart reset_vel='+ str(instance.remd_nstex)\
+          type_line = '        reset_vel='+ str(instance.remd_nstex)\
              +' nstep='+str(instance.md_nstep)\
              +' ntwe='+str(instance.md_ntwe)\
              +' ntwx='+str(instance.md_ntwx)\
index e1ac2b0..d38312f 100644 (file)
@@ -910,6 +910,17 @@ def restart(request, task_id):
     task = get_object_or_404(Task, id=task_id)
     restart0(task)
     return redirect('/')
+   
+def add_restart_inp():
+    with open('file.inp','r') as f1, open ('file.inp.tmp','w') as f2:
+        for line in f1:
+          if 'reset_vel=' in line:
+            f2.write('{:79}'.format('restart'+line[7:]))
+          else:
+            f2.write(line)
+    os.remove('file.inp')
+    os.rename('file.inp.tmp','file.inp')
+    return 
     
 def restart0(task):    
     if os.path.isfile(task.jobdirname+'/finished'):    
@@ -920,10 +931,12 @@ def restart0(task):
     task.save()
     if task.type == 'md':
       os.chdir(task.jobdirname)
+      add_restart_inp()
       ret_code = subprocess.Popen(' /opt/torque/bin/qsub pbs.csh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)            
       os.chdir('..')
     elif task.type == 'remd':
       os.chdir(task.jobdirname)
+      add_restart_inp()
       tmp1=json.loads(task.remd_multi_m)
       nreplicas=sum(map(int, tmp1))
       with open('file_wham.inp','r') as f1, open ('file_wham.tmp','w') as f2: