+int add_atom(t_moldyn *moldyn,int element,double mass,u8 brand,u8 attr,
+ t_3dvec *r,t_3dvec *v) {
+
+ t_atom *atom;
+ void *ptr;
+ int count;
+
+ atom=moldyn->atom;
+ count=(moldyn->count)++;
+
+ ptr=realloc(atom,(count+1)*sizeof(t_atom));
+ if(!ptr) {
+ perror("[moldyn] realloc (add atom)");
+ return -1;
+ }
+ moldyn->atom=ptr;
+
+ atom=moldyn->atom;
+ atom[count].r=*r;
+ atom[count].v=*v;
+ atom[count].element=element;
+ atom[count].mass=mass;
+ atom[count].brand=brand;
+ atom[count].tag=count;
+ atom[count].attr=attr;
+ check_per_bound(moldyn,&(atom[count].r));
+ atom[count].r_0=atom[count].r;
+
+ /* update total system mass */
+ total_mass_calc(moldyn);
+
+ return 0;
+}
+