# Pre-school Courses / Blog

### Introduction to the N-body problem

by Mario A. Rodriguez-MezaLecture-day1-00-Intro.pdf

Course notes: 1, 2

In these lectures the basics of the N-body problem in astrophysics is given. Focusing mainly on the numerical procedures to do simple N-body simulations. In general these procedures consist in constructing the N-body initial conditions, computing the forces between bodies, advancing the system (by solving Newton second law equations) and writing a snapshot of the system. In order to construct initial conditions we will give a brief description of the Monte Carlo method and show how to construct simple initial conditions for astrophysical system of interest, like star cluster, galaxies and sample cubes for cosmological simulations. In particular, attention is given to the following schemes to compute forces among bodies: Particle-Particle, Treecode and TreePM. Also the Smooth Particle Hydrodynamics (SPH) method is review. Simple numerical code written in C will be given to the participants in order they can experiment running simulations and understand some of the main numerical issues of N-body simulations, like numerical errors associated to the force computation, the complexity of the force computation schemes and so on.

### Introduction to the N-body problem II

by Octavio Valenzuela

In these lectures I will introduce the basics concepts of the N-body problem in astrophysics. Particular attention will be given to Particle-Particle (PP), Particle-Mesh (PM) and introduction to the Adaptive Mesh Refinement (AMR) techniques and discussion of the equation of motion integrators. I will define some exercises testing initial conditions and evolution accuracy for spherical isolated systems and small cosmological boxes. In coordination to the Parallel Computing lecturer (Julio Clemente) I will define 3 projects: Parallel Montecarlo Realizations, parallel PP-Nbody code and the parallel solution of a partial differential equation on a mesh.

• octavio

Utilizaremos este software para visualizar los miniproyectos
http://www-hpcc.astro.washington.edu/tools/tipsy/tipsy.html

• Mariana

Hi, I tried to install tipsy from the link posted. I successfully created the Makefile but I got compilation errors. This was done in a MacBook Air with El Capitan OS.

• Matias

I have the same problem, also with El Capitan OS. If someone made it work already, your help would be greatly appreciated.

• octavio

could you post the error message?

• Matias

gcc -c -I. -I. -g -O2 -DPACKAGE_NAME=\”\” -DPACKAGE_TARNAME=\”\” -DPACKAGE_VERSION=\”\” -DPACKAGE_STRING=\”\” -DPACKAGE_BUGREPORT=\”\” -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DX_DISPLAY_MISSING=1 -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 acc_load.c
#include
^
1 error generated.

• I successfully installed tipsy in a Ubuntu 16.04 environment. I’ll make it easier for you. Just download this tar ball ftp://ftp-hpcc.astro.washington.edu/pub/hpcc/tipsy.tar.gz. Then extract all the files (just type tar xvf …) then run this commands:

#Move to the tipsy directory you just extracted
cd tipsy-2.2.3d

#Move to the code directory
cd code

#Run this command
bash configure

This will create a Makefile in the same directory, you may want to check it to see if you if the flags and libraries are correct for your system. Then:

#Now run a make
make

That’s all folks.

• Hiram

Doing what Favio’s intructions say you may encounter this error:

rldefs.h:46:23: termcap.h: No such file or directory

This means you’re missing teamcap libraries, to fix this installed some libraries with this command:

sudo apt-get install libncurses5-dev

This includes libteamcap
After doing this you should follow Favio’s instructions and now it should be fine.

• octavio

Realizaremos 3 proyectos:

Condiciones Iniciales Colapso Frío de una Esfera Homogenea
Visualización con tipsy

Evolución con el código de integración directa PP nbody1.f

• octavio

Exportar nbody1.f a una versión paralela en mpi

• octavio

A los que tengan problema instalando tipsy ya está instalado en atocatl
solicitar a Julio Clemente la cuenta e instrucciones

• Antonio

Buenas.

¿Y a donde le escribimos a Julio Clemente para poder solicitarle el acceso?

Saludos.

• I tried to compile the code and this is the error I get:

nbody1.f:(.text+0xfe9): undefined reference to `energies_’
nbody1.f:(.text+0x1267): undefined reference to `analyze_’
nbody1.f:(.text+0x128f): undefined reference to `writesnapshot_’
nbody1.f:(.text+0x12c5): undefined reference to `savemoment_’
collect2: error: ld returned 1 exit status

• octavio

The problem that Favio reported is because the code has to be compiled together with Nbodyaux.f and the headerfile nbody1.h must be in the same directory. All the files are in the dropbox directory that we provided you

• octavio

The problem that Favio reported is because the code has to be compiled together with Nbodyaux.f and the headerfile nbody1.h must be in the same directory. All the files are in the dropbox directory that we provided you

• Miguel

Hola, donde puedo encontrar los pdf de las presentaciónes?

Ya estan los de Mario en esta pagina, y en cuanto tenga los de Octavio y Julio los subo

• Rebeca

Estoy interesada en trabajar en proyectos que relacionados con condiciones iniciales y salida de los mismos.

• Antonio

¿Alguien ha tenido problemas con openmp con su compilador?

Estoy usando gcc en Os X Yosemite con gcc instalado desde brew y no encuentra la biblioteca.

MacBook-Pro-de-Antonio-2:preescuela antoniogalvan\$ gcc pi_sec.c
#include
^
1 error generated.

• Puedes poner todo tu código por favor?

• Antonio

/**
*Hola mundo en omp
*/

#include
#include

void main(void){
#pragma omp parallel
{
printf(“Hola(%d) “,mi_id);
printf(” Mundo \n”)
}
}

• Antonio

No aparecen las No sé por que, pero están definidas :

#include
#include

• Antonio

“” pareciera que son reservados a los comentarios, pero si están importadas las bibliotecas.

• Antonio

para gfortran-4.9 Hay un error de compilación que es el siguiente:

nbodyaux.f:59.72:

Open(1,file=’particlesA.dat’,status=’unknow’, action=’write’)
1
Error: STATUS specifier in OPEN statement at (1) has invalid value ‘unknow’

La solución en mi caso es por el case sensitive:

reemplazar la linea por:

Open(1,file=’particlesA.dat’,status=’UNKNOWN’, action=’write’)

• octavio

in nbodyaux.f the subroutine writesnapshot has an extra right handed parenthesis
write(10,'(i6,2g11.4,i8,3g12.4))’) it should be like this:
write(10,'(i6,2g11.4,i8,3g12.4)’)