Mostrando postagens com marcador gromacs. Mostrar todas as postagens
Mostrando postagens com marcador gromacs. Mostrar todas as postagens

20100527

Problemas no GROMACS

Tentar ler um trr gerado por um gromacs double num gromacs simples é problema. Problemas com free() e afins, não fui mais fundo.

GROMACS no Ubuntu 8.10

Faça o bootstrap.
./bootstrap
Configure com a precisão desejada (double irá gerar binários com sufixo _d) e habilite a "bendita" geração de bibliotecas dinâmicas.
./configure --enable-double --enable-shared
Caso esqueça de compilar com --enable-shared, limpe o build. Do contrário a compilação falha com algum erro que esqueci de olhar.

20100525

Lendo um arquivo trr do GROMACS

O código abaixo lê um arquivo trr do GROMACS e imprime uma linha com o passo e o tempo correntes e n linhas com velocidades (onde n é o número de átomos).

#include <stdio.h>
#include <trnio.h>

int
main(int argc, char *argv[])
{
        int f, ok, i;
        t_trnheader h;
        rvec *v;

        if(argc < 2){
                fprintf(stderr, "usage: rtrn trajfile\n");
                exit(1);
        }

        f = open_trn(argv[1], "r");
        if(f < 0){
                fprintf(stderr, "open_trn failed to open %s\n", argv[1]);
                exit(1);
        }

        for(;;){
                /* if we find an incomplete header, abort */
                fread_trnheader(f, &h, &ok);
                if(!ok){
                        fprintf(stderr, "incomplete header\n");
                        exit(1);
                }

                v = malloc(h.natoms*sizeof(rvec));
                if(!v){
                        fprintf(stderr, "out of memory\n");
                        exit(1);
                }

                /* if we cannot read the velocities, abort */
                if(!fread_htrn(f, &h, NULL, NULL, v, NULL)){
                        free(v);
                        break;
                }

                printf("step %d time %g\n", h.step, h.t);
                for(i=0; i < h.natoms; i++)
                        printf("%g %g %g\n", v[i][0], v[i][1], v[i][2]);
                free(v);
        }
        return 0;
}
Assumindo GROMACS instalado, compile com algo como:
cc -I/usr/local/gromacs/include/gromacs -Wall -lm -L/usr/lib64 -L/usr/local/gromacs/lib -o x x.c -lgmx -lm -lX11 -lXt -lpthread