Generating Contour Plots of 2D Point Data

From ScorecWiki

Jump to: navigation, search

This page demonstrates how a contour plot can be made from 2D point data.

What follows is an example using a LAMMPS dump file with an energy or stress associated with each atoms position, these instructions could easily be generalized for any 2d point data.

Contents

Download and Compile Triangle

Download the 2D mesh generator Triangle from here. The Makefile is pre-configured for a x86 linux environment. See the README and the Makefile if this not your OS.

 unzip triangle.zip -d triangle
 make 

Generate an Input File for Triangle

Given a LAMMPS dump file with atom coordinates and stress/energy/etc value in the following format:

<atom #> <atom type> <x> <y> <z>

 awk '{if($5 == <z-coordinate>) printf("%d\t%f\t%f\t%f\n", i++, $3, $4, $5}' <dumpFileName> > plane.dat

Modify that file to be read as a triangle input file following this format.

 cp plane.dat plane.node

add this line to the beginning of the plane.node file

<#atoms> 2 <#attributes>

Generate the mesh

Run triangle to generate the mesh

 ./triangle plane.node

Many command line options can be found here.

Create the Tecplot Input File

 touch plane.plt

Add these lines to the plane.plt file

VARIABLES = "X", "Y", "DATA"

ZONE N=<#atoms> ET=TRIANGLE E=<#elements> F=FEPOINT

The number of elements is the first number listed in the .ele file generated by triangle.

Filter out the coordinates from the plane.1.node file that triangle generates and concatenate them to the Tecplot file plane.plt.

 awk '{printf("%f\t%f\t%f\n", $2, $3, $4)}' plane.1.node >> plane.plt

Filter out the connectivity information Add one to each as Tecplot does one based indexing and triangle does zero based.

 awk '{printf("%d\t%d\t%d\n", $2+1, $3+1, $4+1)}' plane.1.ele >> temp

Remove the first and last lines of the file 'temp' and concatenate it to the plane.plt file.

 cat temp >> plane.plt

View in Tecplot

 ssh life
 tecplot

Personal tools