Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ Show the reference:
| `cell:%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf` | cell parameters in Å |
| `shell:b%lf,%lf` | spheres radii in a.u. |
| `shell:%lf,%lf` | spheres radii in Å |
| `cell:0` | disable PBC from the extended xyz file header |
| `cell:b%%lf[,%%lf,%%lf[,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf]]` | cubic / orthogonal / non-orhogonal cell parameters in a.u. |
| `cell:%%lf[,%%lf,%%lf[,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf]]` | cubic / orthogonal / non-orhogonal cell parameters in Å |
| `shell:b%%lf[,%%lf] | sphere(s) radii in a.u. |
| `shell:%%lf[,%%lf] | sphere(s) radii in Å |
| `center:%d` | origin is geometric center (`1`, default) / center of mass (`2`) / as is (`0`) |
| `inertia:%d` | if rotate molecules wrt axis of inertia (`1`) or not (`0`, default) |
| `gui:%d` | normal (default `1`) / headless (`0`) mode |
Expand Down Expand Up @@ -112,9 +117,9 @@ Show the reference:
| `x` | print molecule (Priroda input + bonds)
| `z` | print molecule (`.xyz`)
| `p` | print molecule (input for an `.svg` generator)
| `u` | print current rotation matrix
| `u` | print the current rotation matrix
| `m` | save the current frame ([`.xpm`](https://en.wikipedia.org/wiki/X_PixMap) format)
| `f` | save all frames (vibration mode: save all frames to animate the selected normal mode)
| `f` | save all frames starting from the current one (vibration mode: save all frames to animate the selected normal mode)
| |
| `j` | jump to a frame (will be prompted): `enter` to confirm, `esc` to cancel
| |
Expand Down
7 changes: 6 additions & 1 deletion src/mol/intcoord.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ double intcoord_calc(int r_units_a, int check_n, int z[5], double * r){
}

int intcoord_check(int n, int z[5]){
if(!(z[0]||z[1]||z[2]||z[3]||z[4])){
return 0;
}
switch(z[0]){
case 3 :
if (z[4] < 1 || z[4] > n) z[0] = 0;
Expand All @@ -60,9 +63,11 @@ int intcoord_check(int n, int z[5]){
case 5: // TODO
default:
z[0] = 0;
return -1;
}
switch(z[0]){
case 0 :
PRINT_WARN("check the internal coordintate option ('z:')\n");
return -1;
case 1 :
z[3] = 0;
case 2 :
Expand Down
2 changes: 1 addition & 1 deletion src/v.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int main (int argc, char * argv[]) {
dp->n = dp->n%dp->N;
}
else if(dp->n<0){
dp->n = dp->N-(-dp->n)%dp->N;
dp->n = dp->N-((-dp->n+1)%dp->N)-1;
}

if(!ap.ip.gui){
Expand Down
6 changes: 3 additions & 3 deletions src/v/ac3_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ void ac3_draw(atcoord * ac, rendpars * rend){
XDrawArc(world.dis, world.canv, q>0?world.gc_black:world.gc_dot[1], x-r, y-r, 2*r, 2*r, 0, 360*64);
}

if(rend->num == 1){
if(rend->num == SHOW_NUMBERS){
char text[16];
snprintf(text, sizeof(text), "%d", k+1);
XDRAWSTRING(world.dis, world.canv, world.gc_black, x, y, text, strlen(text));
}
else if(rend->num == -1){
else if(rend->num == SHOW_TYPES){
char text[16];
const char * s = getname(q);
s ? snprintf(text, sizeof(text), "%s", s) : snprintf(text, sizeof(text), "%d", q );
Expand All @@ -92,7 +92,7 @@ void ac3_draw(atcoord * ac, rendpars * rend){
}
double dd = BOND_OFFSET * r / sqrt(r2d);
XDrawLine(world.dis, world.canv, world.gc_black, x+dd*dx, y+dd*dy, x1, y1);
if(rend->bonds==2){
if(rend->bonds==SHOW_LENGTHS){
char text[16];
snprintf(text, sizeof(text), "%.3lf", ac->bonds.r[j]);
XDRAWSTRING(world.dis, world.canv, world.gc_black, x+dx/2, y+dy/2, text, strlen(text));
Expand Down
35 changes: 29 additions & 6 deletions src/v/ac3_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@

#define EPS_INV 1e-15

void mol2cell(atcoord * m){
double rcell[3];
for(int j=0; j<m->n; j++){
double * r = m->r0+j*3;
r3mx(rcell, r, m->cell.rot_to_cell_basis);
for(int i=0; i<3; i++){
if(rcell[i]<-0.5){
rcell[i] += 1.0;
}
else if(rcell[i]>0.5){
rcell[i] -= 1.0;
}
}
r3mx(r, rcell, m->cell.rot_to_lab_basis);
r3cp(m->r+j*3, r);
}
return;
}

static void cell_fill(cellpars * cell, const double abc[9]){
const double * a = abc+0;
const double * b = abc+3;
Expand All @@ -26,21 +45,21 @@ static void cell_fill(cellpars * cell, const double abc[9]){
return;
}

atcoord * atcoord_fill(mol * m0, const int b, const geompars geom, const double cell[9]){
atcoord * atcoord_fill(mol * m0, const render_bonds_t b, const geompars geom, const double cell[9]){
int n = m0->n;

size_t q_size = sizeof(int ) * n;
size_t r_size = sizeof(double) * n*3;
size_t r0_size = sizeof(double) * n*3;
struct {size_t r_size; size_t a_size;} bonds = {0, 0};
if(b!=-1){
if(b!=DISABLE_BONDS){
bonds.a_size = sizeof(int ) * n*BONDS_MAX;
bonds.r_size = sizeof(double) * n*BONDS_MAX;
}
size_t size = sizeof(atcoord) + q_size + r_size + r0_size + bonds.a_size + bonds.r_size;
atcoord * m = calloc(size, 1);

if(b==-1){
if(b==DISABLE_BONDS){
m->r = (double *) (m + 1);
m->r0 = (double *) MEM_END(m,r);
m->q = (int *) MEM_END(m,r0);
Expand All @@ -67,8 +86,8 @@ atcoord * atcoord_fill(mol * m0, const int b, const geompars geom, const double
// we should not change m0
position(&((mol){.n=n, .q=m->q, .r=m->r}), NULL, 1);
}
if(geom.center){
center_mol(n, m->r, geom.center==2 ? m->q : NULL);
if(geom.center!=NO_CENTER){
center_mol(n, m->r, geom.center==CENTER_MASS ? m->q : NULL);
}
veccp(n*3, m->r0, m->r);

Expand All @@ -84,10 +103,14 @@ atcoord * atcoord_fill(mol * m0, const int b, const geompars geom, const double
cell_fill(&m->cell, cell);
}

if(m->cell.boundary==CELL){
mol2cell(m);
}

return m;
}

atcoord * ac3_read(readpars read, int b, const geompars geom, format_t * format){
atcoord * ac3_read(readpars read, const render_bonds_t b, const geompars geom, format_t * format){

mol * m = NULL;
FILE * f = read.f;
Expand Down
6 changes: 3 additions & 3 deletions src/v/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int cli_parse_arg(char * arg, allpars * ap){
}

if(bonds==0){
dp->rend.bonds = -1;
dp->rend.bonds = DISABLE_BONDS;
}

if(tf>0.0){
Expand Down Expand Up @@ -188,11 +188,11 @@ static allpars allpars_init(void){
ap.dp.anim.dt = DEFAULT_TIMEOUT;
ap.dp.anal.symtol = DEFAULT_SYMTOL;
ap.dp.bond.rl = 1.0;
ap.dp.geom.center = 1;
ap.dp.geom.center = CENTER_GEOM;

ap.dp.rend.r = 1.0;
ap.dp.rend.scale = 1.0;
ap.dp.rend.bonds = 1;
ap.dp.rend.bonds = SHOW_BONDS;
mx_id(3, ap.dp.rend.ac3rmx);

return ap;
Expand Down
39 changes: 11 additions & 28 deletions src/v/evr.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,12 @@ void kp_rotz_r(object * ent, drawpars * dp){
return;
}

static void mol2cell(double r[3], cellpars * cell){
double rcell[3];
r3mx(rcell, r, cell->rot_to_cell_basis);
for(int i=0; i<3; i++){
if(rcell[i]<-0.5){
rcell[i] += 1.0;
}
else if(rcell[i]>0.5){
rcell[i] -= 1.0;
}
}
r3mx(r, rcell, cell->rot_to_lab_basis);
return;
}

static void move_pbc(atcoord * m, drawpars * dp, double dr[3]){
for(int j=0; j<m->n; j++){
double * r = m->r0+j*3;
r3add(r, dr);
mol2cell(r, &m->cell);///TODO
r3cp(m->r+j*3, r);
m->rotated = 0;
r3add(m->r0+j*3, dr);
}
mol2cell(m);
m->rotated = 0;
if(dp->rend.bonds>0){
m->bonds.flag = 0;
m->bonds.rl *= RL_MOVE_PBC_SCALE;
Expand Down Expand Up @@ -299,28 +282,28 @@ void kp_bw_toggle(object * ent __attribute__ ((unused)), drawpars * dp){

void kp_l_toggle(object * ent, drawpars * dp){
if(dp->rend.bonds>0){
dp->rend.bonds = 1+!(dp->rend.bonds-1);
dp->rend.bonds = dp->rend.bonds==SHOW_BONDS ? SHOW_LENGTHS : SHOW_BONDS;
exp_redraw(ent, dp);
}
return;
}

void kp_b_toggle(object * ent, drawpars * dp){
if(dp->rend.bonds>-1){
dp->rend.bonds = !dp->rend.bonds;
if(dp->rend.bonds!=DISABLE_BONDS){
dp->rend.bonds = dp->rend.bonds==NO_BONDS ? SHOW_BONDS : NO_BONDS;
exp_redraw(ent, dp);
}
exp_redraw(ent, dp);
return;
}

void kp_n_toggle(object * ent, drawpars * dp){
dp->rend.num = (dp->rend.num == 1) ? 0 : 1;
dp->rend.num = (dp->rend.num == SHOW_NUMBERS) ? NO_ATOM_NUMBERS : SHOW_NUMBERS;
exp_redraw(ent, dp);
return;
}

void kp_t_toggle(object * ent, drawpars * dp){
dp->rend.num = (dp->rend.num == -1) ? 0 : -1;
dp->rend.num = (dp->rend.num == SHOW_TYPES) ? NO_ATOM_NUMBERS : SHOW_TYPES;
exp_redraw(ent, dp);
return;
}
Expand Down Expand Up @@ -424,8 +407,8 @@ void kp_pg(object * ent, drawpars * dp){
}

void kp_jump(object * ent, drawpars * dp){
if(!dp->ui.input){
dp->ui.input = 1;
if(dp->ui.input==NO_INPUT){
dp->ui.input = INPUT_JUMP;
exp_redraw(ent, dp);
}
return;
Expand Down
3 changes: 3 additions & 0 deletions src/v/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ object * read_files(allpars * ap){
}
else{
dp->anal.intcoord[0] = 0;
for(i++; i<fn; i++){
PRINT_WARN("ignoring file '%s'\n", flist[i]);
}
}

return ent;
Expand Down
6 changes: 3 additions & 3 deletions src/v/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void process_input(XKeyEvent * event, drawpars * dp){
if(stop_input){
if(stop_input==1){
switch(dp->ui.input){
case(1):
case(INPUT_JUMP):
{
int frame = atoi(dp->ui.input_text);
frame = MAX(1, MIN(frame, dp->N));
Expand All @@ -38,7 +38,7 @@ static void process_input(XKeyEvent * event, drawpars * dp){
}
}
memset(dp->ui.input_text, 0, STRLEN);
dp->ui.input=0;
dp->ui.input = NO_INPUT;
}
return;
}
Expand Down Expand Up @@ -109,7 +109,7 @@ void main_loop(object * ent, drawpars * dp, ptf kp[NKP]){
}

else if(event->type == KeyPress) {
if(dp->ui.input){
if(dp->ui.input!=NO_INPUT){
process_input(&(event->xkey), dp);
exp_redraw(ent, dp);
}
Expand Down
57 changes: 29 additions & 28 deletions src/v/man.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,30 @@ void printman(FILE * f, char * exename){
\n\
OPTIONS:\n\
\n\
vib:%%d force to show geometries (0) / vibrations (1) \n\
bonds:0 disable bonds\n\
bmax:%%lf max. length of a bond to display\n\
bohr:1 assume input files are in Bohr (default is Å)\n\
dt:%%lf delay between frames in seconds (default %g)\n\
symtol:%%lf tolerance for symmetry determination in Å (default %g) \n\
z:%%d,%%d,%%d,%%d,%%d show an internal coordinate: \n\
1,i,j,0,0 - distance i-j\n\
2,i,j,k,0 - angle i-j-k\n\
3,i,j,k,l - torsion i-j-k-l\n\
rot:%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf rotation matrix to start with (default identity matrix)\n\
frame:%%d frame to start with (default 1)\n\
font:%%s font (xlfd) \n\
colors:%%s colorscheme (\"v\" (default) or \"cpk\") \n\n\
cell:b%%lf,%%lf,%%lf cuboid size in a.u. \n\
cell:%%lf,%%lf,%%lf cuboid size in Å \n\
cell:b%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf cell parameters in a.u. \n\
cell:%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf cell parameters in Å \n\
shell:b%%lf,%%lf spheres radii in a.u. \n\
shell:%%lf,%%lf spheres radii in Å \n\
center:%%d origin is geometric center (1, default) / center of mass (2) / as is (0) \n\
inertia:%%d if rotate molecules wrt axis of inertia (1) or not (0, default) \n\n\
gui:%%d normal (1) / headless (0) mode \n\
com:%%s command sequence for gui:0 \n\
exitcom:%%s command sequence to run on exit (same as for gui:0) \n\
vib:%%d force to show geometries (0) / vibrations (1) \n\
bonds:0 disable bonds\n\
bmax:%%lf max. length of a bond to display\n\
bohr:1 assume input files are in Bohr (default is Å)\n\
dt:%%lf delay between frames in seconds (default %g)\n\
symtol:%%lf tolerance for symmetry determination in Å (default %g) \n\
z:%%d,%%d,%%d,%%d,%%d show an internal coordinate: \n\
1,i,j,0,0 - distance i-j\n\
2,i,j,k,0 - angle i-j-k\n\
3,i,j,k,l - torsion i-j-k-l\n\
rot:%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf rotation matrix to start with (default identity matrix)\n\
frame:%%d frame to start with (default 1)\n\
font:%%s font (xlfd) \n\
colors:%%s colorscheme (\"v\" (default) or \"cpk\") \n\n\
cell:0 disable PBC from the extended xyz file header \n\
cell:b%%lf[,%%lf,%%lf[,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf]] cubic / orthogonal / non-orhogonal cell parameters in a.u. \n\
cell:%%lf[,%%lf,%%lf[,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf]] cubic / orthogonal / non-orhogonal cell parameters in Å \n\
shell:b%%lf[,%%lf] sphere(s) radii in a.u. \n\
shell:%%lf[,%%lf] sphere(s) radii in Å \n\
center:%%d origin is geometric center (1, default) / center of mass (2) / as is (0) \n\
inertia:%%d if rotate molecules wrt axis of inertia (1) or not (0, default) \n\n\
gui:%%d normal (1, default) / headless (0) mode \n\
com:%%s command sequence for gui:0 \n\
exitcom:%%s command sequence to run on exit (same as for gui:0) \n\
\n\
KEYBOARD REFERENCE:\n\
\n\
Expand All @@ -44,7 +43,8 @@ void printman(FILE * f, char * exename){
0 go to the first point \n\
= go to the last point \n\
enter/backspace next/previous point \n\
ins play forwards / stop (vibration mode: animate selected normal mode / stop)\n\
ins play forwards / stop \n\
vibration mode: animate selected normal mode / stop\n\
del play backwards / stop \n\
\n\
home/end zoom in/out \n\
Expand All @@ -63,9 +63,10 @@ void printman(FILE * f, char * exename){
x print molecule (Priroda input + bonds) \n\
z print molecule (.xyz) \n\
p print molecule (input for an .svg generator) \n\
u print current rotation matrix \n\
u print the current rotation matrix \n\
m save the current frame (.xpm format)\n\
f save all frames (vibration mode: save all frames to animate the selected normal mode)\n\
f save all frames starting from the current one \n\
vibration mode: save all frames to animate the selected normal mode) \n\
\n\
j jump to a frame (will be prompted)\n\
\n\
Expand Down
Loading
Loading