ASCII module

ASCII module

This module can be used to extract ASCII data from the out-files generated by IMPETUS Afea Solver. It will gather all the data and store them as a list (array).

This module can be used in combination with *FUNCTION but it's best used post-simulation with atexit.

Module Contents

ascii = Ascii( )
Returns Ascii object.
ascii.read_data( file , entry , dep , dep_value )
Returns a list of values for the specifc file and entry. The variable entry is the column (starting from 0) of the desired data to extract. The last two varables are optional and are used to distinguish between different data within the entry. dep is the desired column and dep_value is the targeted value. For example, the part.out might contain more than one part. If no dependency is chosen, the plot functionality will return all part data. By adding the dependency, one can aim for specific data from the ascii-file.
ascii.get_out_list( )
Returns a list of all .out files from the output directory.
ascii.zip_out_files( zip_file , compression = zipfile.ZIP_DEFLATED )
Creates an zip archive with all .out files from the output directory.
Default compression is set to zipfile.ZIP_DEFLATE but can be changed with the second parameter to:


The function printStatistics() will be executed when the simulation end because of the use of atexit.register().

Python script:
# Import atexit and statistics modules
import atexit
import statistics

# Import the ASCII module
from ascii import Ascii

# Function to be executed when the simulation ends
def printStatistics():
    ascii = Ascii()
    data = ascii.read_data("energy.out", 25)
    median = statistics.median(data)
    mean = statistics.mean(data)
    print("median energy balance:", median)
    print("mean energy balance:", mean)

# Call the above function when the simulation finishes
# Adding the python file to our input file *SCRIPT_PYTHON