Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Trying new capture method and fixed a bug in the output descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Aug 15, 2023
1 parent 4102dd5 commit bdb51ba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import shutil
import warnings
import sys
from py.io import StdCaptureFD
from py.io import StdCapture
from tqdm.auto import tqdm
from typing import (
Literal,
Expand Down Expand Up @@ -425,6 +425,8 @@ def _type_scrub(output_data):
noutput = int((self.param['TSTOP'] - self.param['T0']) / self.param['DT'])
iloop = int((self.param['TSTART'] - self.param['T0']) / self.param['DT'])
twidth = int(np.ceil(np.log10(self.param['TSTOP']/(self.param['DT'] * self.param['ISTEP_OUT']))))
if twidth < 1:
twidth = 1
pre_message = f"Time: {self.param['TSTART']:.{twidth}e} / {self.param['TSTOP']:.{twidth}e} {self.TU_name} "
post_message = f"npl: {self.init_cond['npl'].values[0]} ntp: {self.init_cond['ntp'].values[0]}"
if "nplm" in self.init_cond:
Expand All @@ -434,9 +436,7 @@ def _type_scrub(output_data):
post_message += f" Wall time / step: {0.0:.5e} s"
pbar = tqdm(total=noutput, desc=pre_message, postfix=post_message, bar_format='{l_bar}{bar}{postfix}')
with _cwd(self.simdir):
capture = StdCaptureFD(out=False, in_=False)
out,err = capture.reset()
driver(self.integrator,str(self.param_file), "compact")
res, out, err = StdCapture.call(driver(self.integrator,str(self.param_file), "compact"))
for line in out:
if "SWIFTEST STOP" in line:
process_output = False
Expand Down

0 comments on commit bdb51ba

Please sign in to comment.