Skip to content

Commit

Permalink
Fixed name
Browse files Browse the repository at this point in the history
  • Loading branch information
Chelsea486MHz committed Apr 6, 2020
1 parent bd46aa4 commit 446f6ec
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 64 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Thomas Murgia
Copyright (c) 2018 Sasha Murgia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OBJS := $(shell find $(SRC_DIR) -name "*.o")
NAME := senpai

WARNINGS := -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wuninitialized -Wstrict-prototypes
OPTIONS := -std=c99 -O2 -g -U__STRICT_ANSI__
OPTIONS := -fopenmp -std=c99 -O2 -g -U__STRICT_ANSI__
LIBS := -lm
CFLAGS := -I$(HDR_DIR) $(WARNINGS) $(OPTIONS) $(LIBS) -o $(NAME).bin

Expand Down
22 changes: 1 addition & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The simulation is rendered in a cubic universe of constant size, enforcing perio

## Installation

The first step consists of configuring SENPAI for your machine and use case. This is done by editing the constants in `headers.config.h`.
The first step consists of configuring SENPAI for your machine and use case. This is done by editing the constants in `headers/config.h`.

On UNIX systems, compilation is achieved using the provided makefile. No additional software is required.

Expand Down Expand Up @@ -72,25 +72,5 @@ This will tell SENPAI to simulate the contents of `examples/DES.mol` at STP for

This will have SENPAI load 1000 water molecules from `examples/water.mol`, arrange them so that the total potential energy is lower than 100 pJ, and finally simulate the system at 300 Kelvin for 1 ns, saving the render in `water_render.xyz`.

## Questions and Answers

Q: Why are you doing this? Go out, the sun's out.

A: The sun can't simulate deep eutectic solvents.

-----

Q: Who are you?

A: Thomas Murgia, 19y old at the time of writing this. I'm a second year undergraduate student of chemistry at the Université Toulouse 3 in France.

I plan to keep going with projects like those and hopefully get involved in purely academic and fundamental research in chemistry until the end of my days.

-----

Q: Are you looking for grad programs? Or even internships?

A: Definitely. E-mail me at <[email protected]> (academic email). I'm open to all offers :)


# A complete list of functions and structures is available in the wiki, so as to make contributions easier. Documentation on the way.
2 changes: 1 addition & 1 deletion examples/DES.mol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DES
Murgia Thomas
Murgia Sasha
Deep eutectic solvent (2:1 urea/choline chloride)
38 34 SENPAI
-5.4339 -0.6085 -0.9059 17 -1.0 0.418 4.40 1 1 Chloride
Expand Down
2 changes: 1 addition & 1 deletion examples/co2.mol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CO2
Murgia Thomas
Murgia Sasha
A single carbon dioxide molecule
3 2 SENPAI
-1.1970 0.0000 0.0000 14 -0.326 0.66931 3.03
Expand Down
2 changes: 1 addition & 1 deletion examples/dihydrogen.mol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Dihydrogen
Murgia Thomas
Murgia Sasha
A single dihydrogen molecule
2 1 SENPAI
-0.31 0.0 0.0 2 0.0 0.06 4.02
Expand Down
2 changes: 1 addition & 1 deletion examples/ethane.mol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Ethane
Murgia Thomas
Murgia Sasha
A single ethane molecule
8 7 SENPAI
-0.7560 0.0000 0.0000 8 0.0 1.704 4.23
Expand Down
2 changes: 1 addition & 1 deletion examples/water.mol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Water
Murgia Thomas
Murgia Sasha
A single water molecule
3 2 SENPAI
0.0000 0.0000 0.0000 18 -0.82 0.650 3.166
Expand Down
6 changes: 3 additions & 3 deletions headers/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
" \\___ \\| __| | . ` | ___/ /\\ \\ | | \n"\
" ____) | |____| |\\ | | / ____ \\ _| |_ \n"\
" |_____/|______|_| \\_|_| /_/ \\_\\_____| Simplified Evolutive N-body Processing and Analytics for Integration\n\n"\
"<< 2018-2019 Thomas MURGIA - SENPAI and its source code are licensed under the terms of the MIT license >>\n" \
"<< [email protected] | https://github.com/Garuda1/senpai >> \n"
"<< 2018-2019 Sasha MURGIA - SENPAI and its source code are licensed under the terms of the MIT license >>\n" \
"<< [email protected] | https://github.com/Garuda1/senpai >> \n"


#define TEXT_FAILURE "[" COLOUR_RED "FAILURE" COLOUR_RESET "] "
Expand Down Expand Up @@ -79,7 +79,7 @@
#define TEXT_INFO_ATOMS "Atoms..................%ld\n"
#define TEXT_INFO_TEMPERATURE "Temperature............%lf K\n"
#define TEXT_INFO_PRESSURE "Pressure...............%lf hPa\n"
#define TEXT_INFO_DENSITY "Density................%lf g.cm-1\n"
#define TEXT_INFO_DENSITY "Density................%lf g.cm-3\n"
#define TEXT_INFO_POTENTIAL_ENERGY "Total potential energy.%lf pJ\n"
#define TEXT_INFO_UNIVERSE_SIZE "Universe size ........%lf pm\n"
#define TEXT_INFO_SIMULATION_TIME "Simulation time........%lf ns\n"
Expand Down
35 changes: 18 additions & 17 deletions sources/force.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,19 @@ universe_t *force_angle(vec3d_t *frc, universe_t *universe, const size_t a1, con
pos_backup = ligand->pos;

if (to_ligand.x > 0.5*(universe->size))
ligand->pos.x -= universe->size;
ligand->pos_backup.x -= universe->size;
else if (to_ligand.x <= -0.5*(universe->size))
ligand->pos.x += universe->size;
ligand->pos_backup.x += universe->size;

if (to_ligand.y > 0.5*(universe->size))
ligand->pos.y -= universe->size;
ligand->pos_backup.y -= universe->size;
else if (to_ligand.y <= -0.5*(universe->size))
ligand->pos.y += universe->size;
ligand->pos_backup.y += universe->size;

if (to_ligand.z > 0.5*(universe->size))
ligand->pos.z -= universe->size;
ligand->pos_backup.z -= universe->size;
else if (to_ligand.z <= -0.5*(universe->size))
ligand->pos.z += universe->size;
ligand->pos_backup.z += universe->size;
/* PERIODIC BOUNDARY CONDITIONS */

/* Get its magnitude */
Expand Down Expand Up @@ -256,7 +256,7 @@ universe_t *force_total(vec3d_t *frc, universe_t *universe, const size_t atom_id
{
size_t i;
vec3d_t to_target;
vec3d_t pos_backup;
//vec3d_t pos_backup;
vec3d_t vec_bond;
vec3d_t vec_electrostatic;
vec3d_t vec_lennardjones;
Expand All @@ -270,26 +270,27 @@ universe_t *force_total(vec3d_t *frc, universe_t *universe, const size_t atom_id
{
/* PERIODIC BOUNDARY CONDITIONS */
/* Backup the atom's coordinates */
pos_backup = universe->atom[i].pos;
// pos_backup = universe->atom[i].pos;
universe->atom[i].pos_backup = universe->atom[i].pos;

/* Get the vector going to the target atom */
vec3d_sub(&to_target, &(universe->atom[i].pos), &(universe->atom[atom_id].pos));

/* Temporarily undo the PBC enforcement, if needed */
if (to_target.x > 0.5*(universe->size))
universe->atom[i].pos.x -= universe->size;
universe->atom[i].pos_backup.x -= universe->size;
else if (to_target.x <= -0.5*(universe->size))
universe->atom[i].pos.x += universe->size;
universe->atom[i].pos_backup.x += universe->size;

if (to_target.y > 0.5*(universe->size))
universe->atom[i].pos.y -= universe->size;
universe->atom[i].pos_backup.y -= universe->size;
else if (to_target.y <= -0.5*(universe->size))
universe->atom[i].pos.y += universe->size;
universe->atom[i].pos_backup.y += universe->size;

if (to_target.z > 0.5*(universe->size))
universe->atom[i].pos.z -= universe->size;
universe->atom[i].pos_backup.z -= universe->size;
else if (to_target.z <= -0.5*(universe->size))
universe->atom[i].pos.z += universe->size;
universe->atom[i].pos_backup.z += universe->size;
/* PERIODIC BOUNDARY CONDITIONS */

/* Bonded interractions */
Expand All @@ -300,7 +301,7 @@ universe_t *force_total(vec3d_t *frc, universe_t *universe, const size_t atom_id
return (retstr(NULL, TEXT_FORCE_TOTAL_FAILURE, __FILE__, __LINE__));
if (force_angle(&vec_angle, universe, atom_id, i) == NULL)
return (retstr(NULL, TEXT_FORCE_TOTAL_FAILURE, __FILE__, __LINE__));

;
/* Sum the forces */
vec3d_add(frc, frc, &vec_bond);
vec3d_add(frc, frc, &vec_angle);
Expand All @@ -314,13 +315,13 @@ universe_t *force_total(vec3d_t *frc, universe_t *universe, const size_t atom_id
return (retstr(NULL, TEXT_FORCE_TOTAL_FAILURE, __FILE__, __LINE__));
if (force_lennardjones(&vec_lennardjones, universe, atom_id, i) == NULL)
return (retstr(NULL, TEXT_FORCE_TOTAL_FAILURE, __FILE__, __LINE__));

;
/* Sum the forces */
vec3d_add(frc, frc, &vec_electrostatic);
vec3d_add(frc, frc, &vec_lennardjones);
}
/* Restore the backup coordinates */
universe->atom[i].pos = pos_backup;
//universe->atom[i].pos = pos_backup;
}
}

Expand Down
16 changes: 8 additions & 8 deletions sources/potential.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,25 +250,25 @@ universe_t *potential_total(double *pot, universe_t *universe, const size_t atom
/* PERIODIC BOUNDARY CONDITIONS */
/* Backup the atom's coordinates */
pos_backup = universe->atom[i].pos;

universe->atom[i].pos_backup = universe->atom[i].pos;
/* Get the vector going to the target atom */
vec3d_sub(&to_target, &(universe->atom[i].pos), &(universe->atom[atom_id].pos));

/* Temporarily undo the PBC enforcement, if needed */
if (to_target.x > 0.5*(universe->size))
universe->atom[i].pos.x -= universe->size;
universe->atom[i].pos_backup.x -= universe->size;
else if (to_target.x <= -0.5*(universe->size))
universe->atom[i].pos.x += universe->size;
universe->atom[i].pos_backup.x += universe->size;

if (to_target.y > 0.5*(universe->size))
universe->atom[i].pos.y -= universe->size;
universe->atom[i].pos_backup.y -= universe->size;
else if (to_target.y <= -0.5*(universe->size))
universe->atom[i].pos.y += universe->size;
universe->atom[i].pos_backup.y += universe->size;

if (to_target.z > 0.5*(universe->size))
universe->atom[i].pos.z -= universe->size;
universe->atom[i].pos_backup.z -= universe->size;
else if (to_target.z <= -0.5*(universe->size))
universe->atom[i].pos.z += universe->size;
universe->atom[i].pos_backup.z += universe->size;
/* PERIODIC BOUNDARY CONDITIONS */

/* Bonded interractions */
Expand Down Expand Up @@ -298,7 +298,7 @@ universe_t *potential_total(double *pot, universe_t *universe, const size_t atom
}

/* Restore the backup coordinates */
universe->atom[i].pos = pos_backup;
universe->atom[i].pos_backup = pos_backup;
}
}

Expand Down
21 changes: 13 additions & 8 deletions sources/universe.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,43 +376,47 @@ universe_t *universe_iterate(universe_t *universe, const args_t *args)
{
size_t i; /* Iterator */

{
/* We update the position vector first, as part of the Velocity-Verley integration */
for (i=0; i<(universe->atom_nb); ++i)
if (atom_update_pos(universe, args, i) == NULL)
return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));
{;} //return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));

/* We enforce the periodic boundary conditions */

for (i=0; i<(universe->atom_nb); ++i)
if (atom_enforce_pbc(universe, i) == NULL)
return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));
{;} //return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));

/* Update the force vectors */
/* By numerically differentiating the potential energy... */
if (args->numerical == MODE_NUMERICAL)
{
#pragma omp parallel for num_threads(NUM_THREADS)
for (i=0; i<(universe->atom_nb); ++i)
if (atom_update_frc_numerical(universe, i) == NULL)
return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));
{;} //return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));
}

/* Or analytically solving for force */
else
{
#pragma omp parallel for num_threads(NUM_THREADS)
for (i=0; i<(universe->atom_nb); ++i)
if (atom_update_frc_analytical(universe, i) == NULL)
return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));
{;} //return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));
}

/* Update the acceleration vectors */
for (i=0; i<(universe->atom_nb); ++i)
if (atom_update_acc(universe, i) == NULL)
return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));
{;} //return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));

/* Update the speed vectors */
for (i=0; i<(universe->atom_nb); ++i)
if (atom_update_vel(universe, args, i) == NULL)
return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));

{;} //return (retstr(NULL, TEXT_UNIVERSE_ITERATE_FAILURE, __FILE__, __LINE__));
}
return (universe);
}

Expand Down Expand Up @@ -652,6 +656,7 @@ universe_t *universe_parameters_print(universe_t *universe, const args_t *args)

/* Print some useful information */
puts(TEXT_INFO_REFERENCE);
printf(TEXT_INFO_THREADS, NUM_THREADS);
printf(TEXT_INFO_PATH, args->path);
printf(TEXT_INFO_NAME, universe->meta_name);
printf(TEXT_INFO_AUTHOR, universe->meta_author);
Expand All @@ -673,4 +678,4 @@ universe_t *universe_parameters_print(universe_t *universe, const args_t *args)
printf(TEXT_INFO_ITERATIONS, (long)ceil(args->max_time/args->timestep));

return (universe);
}
}

0 comments on commit 446f6ec

Please sign in to comment.