6
$\begingroup$

I am trying to write the analysis using gmx energy in a bash script. When this is usually passed on a command line, it asks for an input from keyboard to choose the energy term from a list of terms.

This can be automated in a bash script using the keyword echo as follows:

echo Temperature | gmx energy -f md.edr

Or

echo "11 0" | gmx energy -f md.edr

However the problem comes when the energy term is "1/Viscosity" . It recognises only the number 1 and outputs the first energy term. I have tried placing it in quotes, as well as preceding it with a $ sign. None of them work. How to overcome this problem when the energy term doesn't start with a letter?

$\endgroup$

2 Answers 2

3
$\begingroup$

To select multiple energy groups using gmx energy in GROMACS, you can use the newline character \n to separate your selections. This approach can be applied whether you are selecting by number or by name. Here’s how you can do it:

Selecting by numbers.

If you want to select energy groups 1 and 2, you can use the following command:

echo -e "1\n2" | gmx energy -f md.edr

Selecting by number and a name.

If you want to select energy groups 1 and viscosity, use the following command:

echo -e "1\nViscosity" | gmx energy -f md.edr

Selecting by names.

If you want to select energy groups purely by name, use the following command:

echo -e "Temperature\nViscosity" | gmx energy -f md.edr

Mind, both the selection energies will be written to a single file but in different columns.

$\endgroup$
1
  • $\begingroup$ I think Kavya's challenge is automating the analysis of the NEMD approach for computing viscosity, which yields the value 'one per viscosity' (1/Viscosity) in the .edr file. Thus 'echo -e "1\nViscosity" would point GROMACS to output energy values for 1 (Bonds) and then yield an error, as there is no value called "Viscosity". $\endgroup$
    – Bdrs
    Commented Jul 28 at 21:28
1
$\begingroup$

You can make an input file that contains the number(s) for the energy term(s) (input.txt).

Then it can be automated in a bash script in this way: gmx energy -f md.edr <input.txt

$\endgroup$
1
  • 1
    $\begingroup$ Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. $\endgroup$
    – Community Bot
    Commented Jul 26 at 23:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .