visualize.py 1.7 KB
Newer Older
frey_m's avatar
frey_m committed
1 2 3 4
##
# @file visualize.py
# @author Matthias Frey
# @date 14. October 2016, LBNL
5
# @version 1.1 (21. Dec. 2016)
frey_m's avatar
frey_m committed
6
# 
frey_m's avatar
frey_m committed
7 8
# @pre Environment variable OPAL_BUILD has to be set.
# @details Plot the electric self-field, density and self-field
frey_m's avatar
frey_m committed
9 10 11
# potential using the yt framework.
# 1. mpirun -np #cores testSolver
# 2. python visualize.py (make sure you sourced the yt directory $YT_DIR/yt-x86_64/bin/activate)
frey_m's avatar
frey_m committed
12
# @brief Slice plots of plotfiles generated by writePlotFile.H
frey_m's avatar
frey_m committed
13 14

import os
frey_m's avatar
frey_m committed
15 16
import yt

17 18
from tools import doSlicePlot, doProjectionPlot

19 20
try:
    opal = os.environ['OPAL_BUILD']
frey_m's avatar
frey_m committed
21
    ds = yt.load(opal + "ippl/test/AMR/plt0000", dataset_type='opal')
22 23 24 25
    
    ds.print_stats()
    
    print ("Field list:", ds.field_list)
26
    print ("Derived field list:", ds.derived_field_list)    
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    
    
    doSlicePlot(ds, 'z', 'rho', 'C/m**3', 'gray')
    
    doSlicePlot(ds, 'y', 'rho', 'C/m**3', 'gray')
    
    doSlicePlot(ds, 'x', 'rho', 'C/m**3', 'gray')
    
    doProjectionPlot(ds, 'x', 'rho', 'C/m**2', 'gray')
    
    doProjectionPlot(ds, 'y', 'rho', 'C/m**2', 'gray')
    
    doProjectionPlot(ds, 'z', 'rho', 'C/m**2', 'gray')
    
    doSlicePlot(ds, 'z', 'Ex', 'V/m')
    
    doSlicePlot(ds, 'z', 'Ey', 'V/m')
    
    doSlicePlot(ds, 'x', 'Ez', 'V/m')
    
    doSlicePlot(ds, 'z', 'potential', 'V')
frey_m's avatar
frey_m committed
48 49 50 51
    
    doSlicePlot(ds, 'y', 'potential', 'V')
    
    doSlicePlot(ds, 'x', 'potential', 'V')
52 53 54 55 56 57 58 59 60 61 62

    ad = ds.all_data()
    
    print ( ad.quantities.extrema("rho").in_units('C/m**3') )
    print ( ad.quantities.extrema("Ex").in_units('V/m') )
    print ( ad.quantities.extrema("potential").in_units('V') )
    
except KeyError:
    print ("Please export the environment variable 'OPAL_BUILD'.")
except IOError as e:
    print (e.strerror)