Post processing is the last of the five primary steps of simulation development. This step represents the payoff from all the hard work of the previous steps, and it drives the deeper understanding of the design that engineers obtain though simulation. A simulation engineer can significantly improve their understanding, and better communicate that understanding, when they have mastered the skills of post processing. Many plots that simulation engineers develop contain multiple curves, e.g Figure 1, and there is a need to export the data forming the curves to text files. Exported data can then be used in third party software, e.g., MATLAB® or Excel®. These data can also be compared to data in another COMSOL Multiphysics analysis.
Figure 1. Example of multiple curves on the same plot.
To export the data behind the curves, right-click Global 1 plot sub-node and select Add Plot Data to Export. This will add a Plot 1 sub-node under the Export node, as shown in Figure 2. In the Settings window, click Browse… this defines the location and name of the file. Then click the Export button in the Settings window. The Messages window confirms where the file is exported as specified in the File section. The structure of the exported text file is shown in Figure 3.
Figure 2. Settings window for exporting plot.
Figure 3. Default data text file structure for export of multiple curves.
By default, the data are written into a file using the double precision option. To limit the precision to six significant figures, expand the Advanced section in the Settings window and clear the Full precision check box as shown in Figure 4.
Also, to output multiple curves using a separate column for each curve, choose the Append as columns, as shown in Figure 4. This will create a data file where all the curves’ coordinates appear in columns; the first one for the common x-coordinate values and subsequent columns, and one for each curve’s y-coordinate values, as shown in Figure 5. This format can be more convenient for use as input to interpolation functions and for further processing in external software products such as MATLAB® and Excel®.
Figure 4. Adjusting Settings to write data in a single precision format and append multiple curves as columns.
Figure 5. Data file format written using single precision option and append data as columns.
By default, the file type for the exported data is text file (*.txt). Other formats, such as CSV (Comma-Separated-Values) files (*.csv), data files (*.dat), or Microsoft Excel® workbook (*.xlsx) are also available.
Figures 6 and 7 show the settings and the format of the CSV data file.
Figure 6. Selecting file type to write data for the curves.
Figure 7. Data for curves saved in the Excel data file format.
AltaSim Technologies combines consulting and training to help our clients be as independent from us as they choose to be. Our introductory training class on COMSOL Multiphysics is taught as seven (7) separate sessions. Engineers can take all seven sessions for an excellent introduction to solving problems with COMSOL Multiphysics. Another option is for engineers to attend only the sessions of interest. Session 7 covers post-processing. Click here for more information and to register.