int tclcommand_inter_print_all(Tcl_Interp *interp) { int i, j, start = 1; for (i = 0; i < n_bonded_ia; i++) { if (bonded_ia_params[i].type != BONDED_IA_NONE) { if (start) { Tcl_AppendResult(interp, "{", (char *)NULL); start = 0; } else Tcl_AppendResult(interp, " {", (char *)NULL); tclprint_to_result_BondedIA(interp, i); Tcl_AppendResult(interp, "}", (char *)NULL); } } for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { if (checkIfParticlesInteract(i, j)) { if (start) { Tcl_AppendResult(interp, "{", (char *)NULL); start = 0; } else Tcl_AppendResult(interp, " {", (char *)NULL); tclprint_to_result_NonbondedIA(interp, i, j); Tcl_AppendResult(interp, "}", (char *)NULL); } } #ifdef ELECTROSTATICS if(coulomb.method != COULOMB_NONE) { if (start) start = 0; else Tcl_AppendResult(interp, " ", (char *)NULL); /* here the curled braces will be set inside \ref tclprint_to_result_CoulombIA because electrostatics might be using several lists */ tclprint_to_result_CoulombIA(interp); } #endif #ifdef DIPOLES if(coulomb.Dmethod != DIPOLAR_NONE) { if (start) start = 0; else Tcl_AppendResult(interp, " ", (char *)NULL); /* here the curled braces will be set inside \ref tclprint_to_result_DipolarIA because magnetostatics might be using several lists */ tclprint_to_result_DipolarIA(interp); } #endif if(force_cap != 0.0) { char buffer[TCL_DOUBLE_SPACE]; if (start) { Tcl_AppendResult(interp, "{", (char *)NULL); start = 0; } else Tcl_AppendResult(interp, " {", (char *)NULL); if (force_cap == -1.0) Tcl_AppendResult(interp, "forcecap individual", (char *)NULL); else { Tcl_PrintDouble(interp, force_cap, buffer); Tcl_AppendResult(interp, "forcecap ", buffer, (char *) NULL); } Tcl_AppendResult(interp, "}", (char *)NULL); } return (TCL_OK); }
/* Parser routines used in the "analyze stress_tensor" command */ static void tclcommand_analyze_print_stress_tensor_all(Tcl_Interp *interp) { char buffer[TCL_DOUBLE_SPACE + TCL_INTEGER_SPACE + 2]; double value, tvalue[9]; int i, j, k; value = 0.0; Tcl_AppendResult(interp, "{ pressure ", (char *)NULL); for(j=0; j<9; j++) { value = total_p_tensor.data.e[j]; for (i = 1; i < total_p_tensor.data.n/9; i++) value += total_p_tensor.data.e[9*i + j]; Tcl_PrintDouble(interp, value, buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); Tcl_AppendResult(interp, "{ ideal ", (char *)NULL); for(j=0; j<9; j++) { Tcl_PrintDouble(interp, total_p_tensor.data.e[j], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); for(i=0;i<n_bonded_ia;i++) { if (bonded_ia_params[i].type != BONDED_IA_NONE) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, get_name_of_bonded_ia(bonded_ia_params[i].type)," ", (char *)NULL); for(j=0; j<9; j++) { Tcl_PrintDouble(interp, obsstat_bonded(&total_p_tensor, i)[j], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); } } for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { if (checkIfParticlesInteract(i, j)) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); sprintf(buffer, "%d ", j); Tcl_AppendResult(interp, " ", buffer, "nonbonded ", (char *)NULL); for(k=0; k<9; k++) { Tcl_PrintDouble(interp, obsstat_nonbonded(&total_p_tensor, i, j)[k], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); } } Tcl_AppendResult(interp, " { total_nb_intra ", (char *)NULL); for(k=0; k<9; k++) { tvalue[k] = 0.0; for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { tvalue[k] += obsstat_nonbonded_intra(&total_p_tensor_non_bonded, i, j)[k]; } Tcl_PrintDouble(interp, tvalue[k], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); Tcl_AppendResult(interp, " { total_nb_inter ", (char *)NULL); for(k=0; k<9; k++) { tvalue[k] = 0.0; for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { tvalue[k] += obsstat_nonbonded_inter(&total_p_tensor_non_bonded, i, j)[k]; } Tcl_PrintDouble(interp, tvalue[k], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { if (checkIfParticlesInteract(i, j)) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); sprintf(buffer, "%d ", j); Tcl_AppendResult(interp, " ", buffer, "nb_intra_tensor ", (char *)NULL); for(k=0; k<9; k++) { Tcl_PrintDouble(interp, obsstat_nonbonded_intra(&total_p_tensor_non_bonded, i, j)[k], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); } } for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { if (checkIfParticlesInteract(i, j)) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); sprintf(buffer, "%d ", j); Tcl_AppendResult(interp, " ", buffer, "nb_inter_tensor ", (char *)NULL); for(k=0; k<9; k++) { Tcl_PrintDouble(interp, obsstat_nonbonded_inter(&total_p_tensor_non_bonded, i, j)[k], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); } } #ifdef ELECTROSTATICS if(coulomb.method != COULOMB_NONE) { Tcl_AppendResult(interp, "{ coulomb ", (char *)NULL); for(j=0; j<9; j++) { sprintf(buffer, " %lf ", total_p_tensor.coulomb[j]); Tcl_AppendResult(interp, buffer, (char *)NULL); } Tcl_AppendResult(interp, "} ", (char *)NULL); } #endif #ifdef DIPOLES if(coulomb.Dmethod != DIPOLAR_NONE) { fprintf(stderr,"tensor magnetostatics, something should go here, file pressure.cpp ... \n"); } #endif #ifdef VIRTUAL_SITES_RELATIVE buffer[0] = 0; Tcl_AppendResult(interp, "{ vs_relative ", buffer, (char *)NULL); for (j=0;j<9;j++) { sprintf(buffer, "%g", total_p_tensor.vs_relative[j]); Tcl_AppendResult(interp, buffer, (char *)NULL); Tcl_AppendResult(interp, " ", (char *)NULL); } Tcl_AppendResult(interp, " }", (char *)NULL); #endif }
static void tclcommand_analyze_print_pressure_all(Tcl_Interp *interp) { char buffer[TCL_DOUBLE_SPACE + TCL_INTEGER_SPACE + 2]; double value; int i, j; value = 0.0; value = total_pressure.data.e[0]; for (i = 1; i < total_pressure.data.n; i++) value += total_pressure.data.e[i]; Tcl_PrintDouble(interp, value, buffer); Tcl_AppendResult(interp, "{ pressure ", buffer, " } ", (char *)NULL); Tcl_PrintDouble(interp, total_pressure.data.e[0], buffer); Tcl_AppendResult(interp, "{ ideal ", buffer, " } ", (char *)NULL); for(i=0;i<n_bonded_ia;i++) { if (bonded_ia_params[i].type != BONDED_IA_NONE) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); Tcl_PrintDouble(interp, *obsstat_bonded(&total_pressure, i), buffer); Tcl_AppendResult(interp, get_name_of_bonded_ia(bonded_ia_params[i].type), " ", buffer, " } ", (char *) NULL); } } for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { if (checkIfParticlesInteract(i, j)) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); sprintf(buffer, "%d ", j); Tcl_AppendResult(interp, " ", buffer, (char *)NULL); Tcl_PrintDouble(interp, *obsstat_nonbonded(&total_pressure, i, j), buffer); Tcl_AppendResult(interp, "nonbonded ", buffer, " } ", (char *)NULL); } } /* In case we need intra- and inter- nonbonded (nb) contribution of total pressure */ value = 0.0; for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { value += *obsstat_nonbonded_intra(&total_pressure_non_bonded, i, j); } Tcl_PrintDouble(interp, value, buffer); Tcl_AppendResult(interp, " { total_nb_intra ", (char *)NULL); Tcl_PrintDouble(interp, value, buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_AppendResult(interp, "} ", (char *)NULL); value = 0.0; for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { value += *obsstat_nonbonded_inter(&total_pressure_non_bonded, i, j); } Tcl_PrintDouble(interp, value, buffer); Tcl_AppendResult(interp, " { total_nb_inter ", (char *)NULL); Tcl_PrintDouble(interp, value, buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_AppendResult(interp, "} ", (char *)NULL); for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { if (checkIfParticlesInteract(i, j)) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); sprintf(buffer, "%d ", j); Tcl_AppendResult(interp, " ", buffer, (char *)NULL); Tcl_PrintDouble(interp, *obsstat_nonbonded_intra(&total_pressure_non_bonded, i, j), buffer); Tcl_AppendResult(interp, "nb_intra ", buffer, " } ", (char *)NULL); } } for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { if (checkIfParticlesInteract(i, j)) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); sprintf(buffer, "%d ", j); Tcl_AppendResult(interp, " ", buffer, (char *)NULL); Tcl_PrintDouble(interp, *obsstat_nonbonded_inter(&total_pressure_non_bonded, i, j), buffer); Tcl_AppendResult(interp, "nb_inter ", buffer, " } ", (char *)NULL); } } #if defined(ELECTROSTATICS) || defined (DIPOLES) if( #ifdef ELECTROSTATICS coulomb.method != COULOMB_NONE #else 0 #endif || #ifdef DIPOLES coulomb.Dmethod != DIPOLAR_NONE #else 0 #endif ) { /* total Coulomb pressure */ value = total_pressure.coulomb[0]; for (i = 1; i < total_pressure.n_coulomb; i++) value += total_pressure.coulomb[i]; for (i = 0; i < total_pressure.n_dipolar; i++) value += total_pressure.dipolar[i]; Tcl_PrintDouble(interp, value, buffer); #if defined(ELECTROSTATICS) && defined (DIPOLES) Tcl_AppendResult(interp, "{ coulomb+magdipoles ", buffer, (char *)NULL); #else #if defined(ELECTROSTATICS) Tcl_AppendResult(interp, "{ coulomb ", buffer, (char *)NULL); #endif #if defined(DIPOLES) Tcl_AppendResult(interp, "{ magdipoles ", buffer, (char *)NULL); #endif #endif /* if it is split up, then print the split up parts */ if (total_pressure.n_coulomb > 1) { for (i = 0; i < total_pressure.n_coulomb; i++) { Tcl_PrintDouble(interp, total_pressure.coulomb[i], buffer); Tcl_AppendResult(interp, " ", buffer, (char *)NULL); } } Tcl_AppendResult(interp, " } ", (char *)NULL); } #endif #ifdef VIRTUAL_SITES_RELATIVE buffer[0] = 0; Tcl_AppendResult(interp, "{ vs_relative ", buffer, (char *)NULL); Tcl_PrintDouble(interp, total_pressure.vs_relative[0], buffer); Tcl_AppendResult(interp, buffer, (char *)NULL); Tcl_AppendResult(interp, " }", (char *)NULL); #endif }
static void tclcommand_analyze_print_all(Tcl_Interp *interp) { char buffer[TCL_DOUBLE_SPACE + TCL_INTEGER_SPACE + 2]; double value; int i, j; value = total_energy.data.e[0]; for (i = 1; i < total_energy.data.n; i++) value += total_energy.data.e[i]; for (i = 0; i < n_external_potentials; i++) { value+=external_potentials[i].energy; } Tcl_PrintDouble(interp, value, buffer); Tcl_AppendResult(interp, "{ energy ", buffer, " } ", (char *)NULL); Tcl_PrintDouble(interp, total_energy.data.e[0], buffer); Tcl_AppendResult(interp, "{ kinetic ", buffer, " } ", (char *)NULL); for(i=0;i<n_bonded_ia;i++) { if (bonded_ia_params[i].type != BONDED_IA_NONE) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); Tcl_PrintDouble(interp, *obsstat_bonded(&total_energy, i), buffer); Tcl_AppendResult(interp, get_name_of_bonded_ia(bonded_ia_params[i].type), " ", buffer, " } ", (char *) NULL); } } for (i = 0; i < n_particle_types; i++) for (j = i; j < n_particle_types; j++) { if (checkIfParticlesInteract(i, j)) { sprintf(buffer, "%d ", i); Tcl_AppendResult(interp, "{ ", buffer, (char *)NULL); sprintf(buffer, "%d ", j); Tcl_AppendResult(interp, " ", buffer, (char *)NULL); Tcl_PrintDouble(interp, *obsstat_nonbonded(&total_energy, i, j), buffer); Tcl_AppendResult(interp, "nonbonded ", buffer, " } ", (char *)NULL); } } #if defined(ELECTROSTATICS) || defined(DIPOLES) if( #if defined(ELECTROSTATICS) && defined(DIPOLES) coulomb.method != COULOMB_NONE || coulomb.Dmethod != DIPOLAR_NONE #elif defined(ELECTROSTATICS) coulomb.method != COULOMB_NONE #elif defined(DIPOLES) coulomb.Dmethod != DIPOLAR_NONE #endif ) { /* total Coulomb energy */ value = 0; for (i = 0; i < total_energy.n_coulomb; i++) value += total_energy.coulomb[i]; for (i = 0; i < total_energy.n_dipolar; i++) value += total_energy.dipolar[i]; Tcl_PrintDouble(interp, value, buffer); #if defined(ELECTROSTATICS) && defined(DIPOLES) Tcl_AppendResult(interp, "{ coulomb+magdipoles ", buffer, (char *)NULL); #elif defined(ELECTROSTATICS) Tcl_AppendResult(interp, "{ coulomb ", buffer, (char *)NULL); #elif defined(DIPOLES) Tcl_AppendResult(interp, "{ magdipoles ", buffer, (char *)NULL); #endif /* if it is split up, then print the split up parts */ #ifdef ELECTROSTATICS if (total_energy.n_coulomb > 1) { for (i = 0; i < total_energy.n_coulomb; i++) { Tcl_PrintDouble(interp, total_energy.coulomb[i], buffer); Tcl_AppendResult(interp, " ", buffer, (char *)NULL); } } Tcl_AppendResult(interp, " }", (char *)NULL); #endif #ifdef DIPOLES if (total_energy.n_dipolar > 1) { for (i = 0; i < total_energy.n_dipolar; i++) { Tcl_PrintDouble(interp, total_energy.dipolar[i], buffer); Tcl_AppendResult(interp, " ", buffer, (char *)NULL); } } #endif } #endif if (n_external_potentials > 0) { Tcl_AppendResult(interp, " { external_potential", (char *)NULL); for (i = 0; i < n_external_potentials; i++) { Tcl_PrintDouble(interp, external_potentials[i].energy, buffer); Tcl_AppendResult(interp, " ", buffer, (char *)NULL); } } }