/* shift the crystal along axis-i by amount d*lengthscale*XTAL_SHIFT_GEAR */ bool xtal_shift (int iw, int i, double d) { if (!n[iw].xtal_mode) { printf ("Crystal translation is only available under Xtal mode.\n"); return(FALSE); } d *= lengthscale * XTAL_SHIFT_GEAR; V3ADDmuL (d, AX_3D[iw].V[i], n[iw].xtal_origin); atom_xtal_origin (n[iw].xtal_origin); if (n[iw].bond_mode) bond_xtal_origin_update (iw); else n[iw].bond_xtal_origin_need_update = TRUE; return (TRUE); } /* end xtal_shift() */
bool xtal_origin_zero (int iw) { if (!n[iw].xtal_mode) { printf ("Crystal translation is only available under Xtal mode.\n"); return(FALSE); } if (V3LENGTH(n[iw].xtal_origin) < TINY) return(FALSE); V3ZERO(n[iw].xtal_origin); atom_xtal_origin (n[iw].xtal_origin); if (n[iw].bond_mode) bond_xtal_origin_update (iw); else n[iw].bond_xtal_origin_need_update = TRUE; return (TRUE); } /* end xtal_origin_zero() */
/* Use pointer device to shift the crystal */ bool pointer_xtal_shift (int iw, int to_x, int to_y) { int i; double s[3], xx_last[3], xx_now[3]; if (!n[iw].xtal_mode) { printf ("Crystal translation is only available under Xtal mode.\n"); return(FALSE); } if ((n[iw].lx == to_x) && (n[iw].ly == to_y)) return (FALSE); V3mM3 (AX_3D[iw].x, HI, s); if (V3XIN(s,0,1)) return(pointer_grab_xtal_shift(iw,to_x,to_y)); i = Eyesight_Intersect_H_Box (iw, n[iw].lx, n[iw].ly, xx_last); if (i >= 0) n[iw].last_surface_id = i; else if (Eyesight_Intersect_H_Surface (H, n[iw].last_surface_id, AX_3D[iw].x, AX_3D[iw].V, (n[iw].lx + 0.5 - AX_3D[iw].wx) / AX_3D[iw].k, (n[iw].ly + 0.5 - AX_3D[iw].wy) / AX_3D[iw].k, s, xx_last) <= 0) { n[iw].lx = to_x; n[iw].ly = to_y; return(FALSE); } i = Eyesight_Intersect_H_Box (iw, to_x, to_y, xx_now); if (i >= 0) n[iw].last_surface_id = i; else if (Eyesight_Intersect_H_Surface (H, n[iw].last_surface_id, AX_3D[iw].x, AX_3D[iw].V, (to_x + 0.5 - AX_3D[iw].wx) / AX_3D[iw].k, (to_y + 0.5 - AX_3D[iw].wy) / AX_3D[iw].k, s, xx_now) <= 0) { n[iw].lx = to_x; n[iw].ly = to_y; return(FALSE); } n[iw].lx = to_x; n[iw].ly = to_y; V3AdD(xx_last,n[iw].xtal_origin); V3SuB(n[iw].xtal_origin,xx_now); atom_xtal_origin (n[iw].xtal_origin); if (n[iw].bond_mode) bond_xtal_origin_update (iw); else n[iw].bond_xtal_origin_need_update = TRUE; return (TRUE); } /* end pointer_xtal_shift() */
bool xtal_origin_goto (int iw) { double old_s[3], s[3]; char danswer[MAX_FILENAME_SIZE],*answer; if (!n[iw].xtal_mode) { printf ("Crystal translation is only available under Xtal mode.\n"); return(FALSE); } V3mM3 (AX_3D[iw].x, HI, old_s); xterm_get_focus(iw); clear_stdin_buffer(); sprintf (danswer, "%g %g %g", old_s[0],old_s[1],old_s[2]); answer = readline_gets("\nCrystal origin s0,s1,s2",danswer); sscanf (answer, "%lf %lf %lf", s, s+1, s+2); xterm_release_focus(iw); V3TRIM (s,s); if (V3EQ(old_s,s)) return(FALSE); V3mM3 (s, H, n[iw].xtal_origin); atom_xtal_origin (n[iw].xtal_origin); if (n[iw].bond_mode) bond_xtal_origin_update (iw); else n[iw].bond_xtal_origin_need_update = TRUE; return (TRUE); } /* end xtal_origin_goto() */
/* use pointer device to shift the crystal */ bool pointer_grab_xtal_shift (int iw, int to_x, int to_y) { double z, tmp[3]; if (!n[iw].xtal_mode) { printf ("Crystal translation is only available under Xtal mode.\n"); return(FALSE); } if ((n[iw].lx == to_x) && (n[iw].ly == to_y)) return (FALSE); if (n[iw].anchor >= 0) V3SUB (B->BALL[n[iw].anchor].x, AX_3D[iw].x, tmp); else V3SUB (n[iw].hook, AX_3D[iw].x, tmp); z = V3DOT (AX_3D[iw].V[2], tmp); tmp[0] = (n[iw].lx - to_x) / AX_3D[iw].k * z; V3ADDmuL (tmp[0], AX_3D[iw].V[0], n[iw].xtal_origin); tmp[1] = (n[iw].ly - to_y) / AX_3D[iw].k * z; V3ADDmuL (tmp[1], AX_3D[iw].V[1], n[iw].xtal_origin); n[iw].lx = to_x; n[iw].ly = to_y; atom_xtal_origin (n[iw].xtal_origin); if (n[iw].bond_mode) bond_xtal_origin_update (iw); else n[iw].bond_xtal_origin_need_update = TRUE; return (TRUE); } /* end pointer_grab_xtal_shift() */
/* Reload the configuration but keeping the rendering state */ void reload_config (int iw, bool term_input_filename) { register int i; int j, k, old_np; char fname[MAX_FILENAME_SIZE], oldfname[MAX_FILENAME_SIZE]; V3 hook_s, tmp, dx; char *old_symbol=NULL; bool incompatible_config; strcpy(oldfname, config_fname); if (n[iw].anchor >= 0) { /* the new configuration may not even have the atom */ V3EQV (B->BALL[n[iw].anchor].x, n[iw].hook); n[iw].anchor = -1; } /* hook_s[] is what is kept invariant */ V3mM3 (n[iw].hook, HI, hook_s); if (term_input_filename) { xterm_get_focus(iw); clear_stdin_buffer(); strcpy(fname,readline_gets("\nLoad configuration",config_fname)); strcpy(config_fname,fname); xterm_release_focus(iw); } if (!Fexists(config_fname)) { printf ("\n** %s: **\n", config_fname); printf ("** There is no such file! **\n"); strcpy(config_fname, oldfname); return; } if (!Freadable(config_fname)) { printf ("\n** %s: **\n", config_fname); printf ("** This file is unreadable! **\n"); strcpy(config_fname, oldfname); return; } cr(); old_np = np; CLONE(symbol, SYMBOL_SIZE*np, char, old_symbol); i = CONFIG_LOAD (config_fname, Config_Aapp_to_Alib); for (k=0; k<CONFIG_num_auxiliary; k++) if (*blank_advance(CONFIG_auxiliary_name[k])==EOS) sprintf(CONFIG_auxiliary_name[k], "auxiliary%d", k); rebind_CT (Config_Aapp_to_Alib, "", ct, &tp); cr(); Neighborlist_Recreate_Form (Config_Aapp_to_Alib, ct, N); if (i == CONFIG_CFG_LOADED) N->s_overflow_err_handler = NEIGHBORLIST_S_OVERFLOW_ERR_HANDLER_FOLD_INTO_PBC; else N->s_overflow_err_handler = NEIGHBORLIST_S_OVERFLOW_ERR_HANDLER_BOUNDING_BOX; N->small_cell_err_handler = NEIGHBORLIST_SMALL_CELL_ERR_HANDLER_MULTIPLY; for (i=0; i<ct->t; i++) for (j=i; j<ct->t; j++) for (k=0; k<rcut_patch_top; k++) if ( ( ( (rcut_patch[k].Zi == ct->Z[i]) && (rcut_patch[k].Zj == ct->Z[j]) ) || ( (rcut_patch[k].Zi == ct->Z[j]) && (rcut_patch[k].Zj == ct->Z[i]) ) ) ) NEIGHBOR_TABLE(N->rcut,ct,i,j) = NEIGHBOR_TABLE(N->rcut,ct,j,i) = rcut_patch[k].rcut; Neighborlist_Recreate (Config_Aapp_to_Alib, stdout, ct, &tp, N); V3mM3 (hook_s, H, tmp); V3SUB (tmp, n[iw].hook, dx); V3EQV (tmp, n[iw].hook); V3AdD (dx, AX_3D[iw].x); M3InV (H, HI, volume); lengthscale = cbrt(volume); V3ASSIGN (0.5,0.5,0.5,tmp); V3mM3 (tmp, H, cm); geo_clear_has_evaluated_flags(); evaluate_geo_measures(); Free(s1); Free(mass); if ( ComputeLeastSquareStrain ) { if (ConfigChecksum(Config_Aapp_to_Alib) != ref->checksum) printf ("This configuration is not isoatomic with the imprinted " "reference\n%s. Least-square strain NOT calculated.\n", ref_fbasename); else LeastSquareStrain_Append(); } incompatible_config = (np != old_np) || memcmp(symbol, old_symbol, SYMBOL_SIZE*MIN(np,old_np)); Free(old_symbol); if (incompatible_config) Config_to_3D_Balls (n[iw].atom_r_ratio); else for (i=0; i<np; i++) V3mM3 ( &(s[DIMENSION*i]), H, B->BALL[i].x ); atom_xtal_origin (n[iw].xtal_origin); if (!n[iw].auxiliary_thresholds_rigid) { for (i=0; i<CONFIG_num_auxiliary; i++) reset_auxiliary_threshold(iw,i); for (i=0; i<MAX_GEO_MEASURES; i++) if (geolist[i].has_evaluated) reset_auxiliary_threshold(iw,CONFIG_MAX_AUXILIARY+i); } if (!temporary_disable_bond) Config_to_3D_Bonds (n[iw].bond_radius); select_fbasename (config_fname); if ((n[iw].xtal_mode) && (n[iw].color_mode == COLOR_MODE_COORD)) assign_coordination_color(iw); else if (n[iw].color_mode == COLOR_MODE_AUXILIARY) color_encode_auxiliary(iw); else if (n[iw].color_mode == COLOR_MODE_SCRATCH) scratch_color (iw); else { strcpy (AX_title[iw],fbasename); AXSetName (iw); XStoreName(AX_display[iw],xterm_win,AX_title[iw]); XSetIconName(AX_display[iw],xterm_win,AX_title[iw]); if (!temporary_disable_bond) { bond_xtal_origin_update (iw); bond_atom_color_update (iw); } } return; } /* end reload_config() */