xref: /petsc/src/ts/tutorials/extchem.py (revision f748bf6bfc83f133d5068e6a5445afd45844ada1)
1*1b37a2a7SPierre Jolivet#!/usr/bin/env python3
2c4762a1bSJed Brown#
3c4762a1bSJed Brown#    Reads in the output trajectory data from a run of extchem and
4c4762a1bSJed Brown#  formats it for graphing
5c4762a1bSJed Brown#
6c4762a1bSJed Brown#  Make sure $PETSC_DIR/bin is in your PYTHONPATH
7c4762a1bSJed Brown#
8c4762a1bSJed Brownfrom __future__ import print_function
9c4762a1bSJed Brownimport sys
10c4762a1bSJed Brownimport PetscBinaryIOTrajectory
11c4762a1bSJed Brown
12c4762a1bSJed Brownif __name__ ==  '__main__':
13c4762a1bSJed Brown  if len(sys.argv) > 1:
14c4762a1bSJed Brown    directory = sys.argv[1]
15c4762a1bSJed Brown  else:
16c4762a1bSJed Brown    directory = 'Visualization-data'
17c4762a1bSJed Brown  (t,v,names) = PetscBinaryIOTrajectory.ReadTrajectory(directory)
18c4762a1bSJed Brown#  PetscBinaryIOTrajectory.PlotTrajectories(t,v,names,['Temp','CO','CO2','H2O','H2','O2','CH4','C2H2','N2'])
19c4762a1bSJed Brown#
20c4762a1bSJed Brown#  Code is currently hardwired to display certain species only, edit the list below to display the species you want displayed
21c4762a1bSJed Brown#
22c4762a1bSJed Brown  for i in range(0,len(t)-1):
23c4762a1bSJed Brown    print(t[i],v[i][names.index('Temp')],v[i][names.index('CH4')],v[i][names.index('O2')],v[i][names.index('N2')],v[i][names.index('CO')],v[i][names.index('CO2')],v[i][names.index('O')],v[i][names.index('OH')],v[i][names.index('H2O')])
24c4762a1bSJed Brown
25c4762a1bSJed Brown
26