1#!/usr/local/bin/bash
2#
3# Copyright 2009-2017 The VOTCA Development Team (http://www.votca.org)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18if [[ $1 = "--help" ]]; then
19cat <<EOF
20${0##*/}, version %version%
21This script calcs the pressure for lammps and writes it to outfile
22
23Usage: ${0##*/} outfile
24
25Used external packages: lammps
26EOF
27   exit 0
28fi
29
30[[ -z $1 ]] && die "${0##*/}: Missing argument"
31
32p_file="$(csg_get_property cg.inverse.lammps.pressure_file)"
33
34[[ -f ${p_file} ]] || die "${0##*/}: pressure file '${p_file}' doesn't exist"
35
36p_now=$(awk 'NR > 1 {avg += $1} END {printf "%.16f\n", avg/(NR-1)}' ${p_file}) || die "${0##*/}: pressure averaging failed"
37echo "Pressure=${p_now}" > "$1"
38