Beispiel #1
0
//output dimer configurations to pqr for verification
void output_pqrs(system_t *system, int nCurves, curveData_t *curve) {
    int i;
    char filename[500];

    for (i = 0; i < nCurves; i++) {
        // Apply rotation associated with i-th curve and separate COM by 5 Angstroms
        surface_dimer_geometry(system, 5.0, curve[i].alpha1, curve[i].beta1, curve[i].gamma1,
                               curve[i].alpha2, curve[i].beta2, curve[i].gamma2, 0);
        sprintf(filename,
                "%s.pqr", curve[i].id);
        write_molecules_wrapper(system, filename);

        // Restore the molecule to its initial orientation
        surface_dimer_geometry(system, 0.0, curve[i].alpha1, curve[i].beta1, curve[i].gamma1,
                               curve[i].alpha2, curve[i].beta2, curve[i].gamma2, 1);
    }

    return;
}
Beispiel #2
0
//apply trial parameters
void get_curves(system_t *system, int nCurves, curveData_t *curve, double r_min, double r_max, double r_inc) {
    int i;

    for (i = 0; i < nCurves; i++) {
        // Apply rotation associated with i-th curve
        surface_dimer_geometry(system, r_min, curve[i].alpha1, curve[i].beta1, curve[i].gamma1,
                               curve[i].alpha2, curve[i].beta2, curve[i].gamma2, 0);
        // Perform the calculation
        surface_curve(system, r_min, r_max, r_inc, curve[i].output);

        // Restore the molecule to its initial orientation
        surface_dimer_geometry(system, r_min, curve[i].alpha1, curve[i].beta1, curve[i].gamma1,
                               curve[i].alpha2, curve[i].beta2, curve[i].gamma2, 1);
    }
    // Reset to origin
    surface_dimer_geometry(system, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);

    return;
}
Beispiel #3
0
void surface_curve(system_t *system, double r_min, double r_max, double r_inc, double *curve) {
    int i;
    double r;

    for (r = r_min, i = 0; r <= r_max; r += r_inc, i++) {
        surface_dimer_geometry(system, r, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
        curve[i] = surface_energy(system, ENERGY_TOTAL);
    }

    return;
}
Beispiel #4
0
/* calculate the isotropic potential energy surface of a molecule */
int surface(system_t *system) {

	int ao, bo, go, am, bm, gm, surf_print; /* for surf_output */
	int avg_counter;
	double avg_factor;
	double r, pe_es, pe_rd, pe_polar, pe_vdw, pe_total;
	double pe_total_avg, pe_es_avg, pe_rd_avg, pe_polar_avg, pe_vdw_avg;
	double alpha_origin, beta_origin, gamma_origin;
	double alpha_move, beta_move, gamma_move;

	/* open surface trajectory file */
	if(system->surf_output) {
		if(open_surf_traj_file(system) < 0)
			error("Surface: could not open surface trajectory file\n");
	}

	/* output the potential energy curve */
	if(system->surf_preserve) {	/* preserve the orientation and only calculate based on displacement */

		//apply rotation if given in input file
		if ( system->surf_preserve_rotation_on != NULL ) {
			surface_dimer_geometry(system, 0.0, 
				system->surf_preserve_rotation_on->alpha1,
				system->surf_preserve_rotation_on->beta1,
				system->surf_preserve_rotation_on->gamma1,
				system->surf_preserve_rotation_on->alpha2,
				system->surf_preserve_rotation_on->beta2,
				system->surf_preserve_rotation_on->gamma2, 0);
				printf("SURFACE: Setting preserve angles (radians) for molecule 1: %lf %lf %lf\n",
					system->surf_preserve_rotation_on->alpha1,
					system->surf_preserve_rotation_on->beta1,
					system->surf_preserve_rotation_on->gamma1);
				printf("SURFACE: Setting preserve angles (radians) for molecule 2: %lf %lf %lf\n",
					system->surf_preserve_rotation_on->alpha2,
					system->surf_preserve_rotation_on->beta2,
					system->surf_preserve_rotation_on->gamma2);
		}
		
		for(r = system->surf_min; r <= system->surf_max; r += system->surf_inc) {

			/* calculate the energy */
			surface_dimer_geometry(system, r, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);

			if(system->surf_decomp) {
				pe_es = surface_energy(system, ENERGY_ES);
				pe_rd = surface_energy(system, ENERGY_RD);
				pe_polar = surface_energy(system, ENERGY_POLAR);
				pe_vdw = surface_energy(system, ENERGY_VDW);
				printf("%.5f %.5f %.5f %.5f %.5f\n", r, pe_es, pe_rd, pe_polar, pe_vdw);
				fflush(stdout);
			} else {
				pe_total = surface_energy(system, ENERGY_TOTAL);
				printf("%.5f %.5f\n", r, pe_total);
				fflush(stdout);
			}

		}

	} else {	/* default is to do isotropic averaging */

		for(r = system->surf_min; r <= system->surf_max; r+= system->surf_inc) {

			/* zero the averages for this r value */
			avg_counter = 0;
			pe_total_avg = 0;
			pe_es_avg = 0;
			pe_rd_avg = 0;
			pe_polar_avg = 0;
			pe_vdw_avg = 0;
			ao = 0;
			bo = 0;
			go = 0;
			am = 0;
			bm = 0;
			gm = 0;
			surf_print = 0;

			/* average over the angles */
			for(alpha_origin = 0; alpha_origin <= 2.0*M_PI; alpha_origin += system->surf_ang) {
				for(beta_origin = 0; beta_origin <= M_PI; beta_origin += system->surf_ang) {
					for(gamma_origin = 0; gamma_origin <= 2.0*M_PI; gamma_origin += system->surf_ang) {
						for(alpha_move = 0; alpha_move <= 2.0*M_PI; alpha_move += system->surf_ang) {
							for(beta_move = 0; beta_move <= M_PI; beta_move += system->surf_ang) {
								for(gamma_move = 0; gamma_move <= 2.0*M_PI; gamma_move += system->surf_ang) {

									++gm;
									++avg_counter;
									avg_factor = ((double)(avg_counter - 1))/((double)(avg_counter));

									surface_dimer_geometry(system, r, alpha_origin, beta_origin, gamma_origin, alpha_move, beta_move, gamma_move, 0);

									if(system->surf_print_level == 6)
										surf_print = 1;

									if(system->surf_output && surf_print == 1)
										write_surface_traj(system->file_pointers.fp_surf, system);

									surf_print = 0; /* turn off printing */

									if(system->surf_decomp) {

										pe_es = surface_energy(system, ENERGY_ES);
										pe_rd = surface_energy(system, ENERGY_RD);
										pe_polar = surface_energy(system, ENERGY_POLAR);
										pe_vdw = surface_energy(system, ENERGY_VDW);

										pe_es_avg = pe_es_avg*avg_factor + (pe_es/((double)avg_counter));
										pe_rd_avg = pe_rd_avg*avg_factor + (pe_rd/((double)avg_counter));
										pe_polar_avg = pe_polar_avg*avg_factor + (pe_polar/((double)avg_counter));
										pe_vdw_avg = pe_vdw_avg*avg_factor + (pe_vdw/((double)avg_counter));


									} else {

										pe_total = surface_energy(system, ENERGY_TOTAL);
										pe_total_avg = pe_total_avg*avg_factor + (pe_total/((double)avg_counter));

									}
									//unrotate (not the most efficent thing to be doing, but oh well)
									surface_dimer_geometry(system, 0.0, alpha_origin, beta_origin, gamma_origin, alpha_move, beta_move, gamma_move, 1);

								} /* end gamma_move */
								++bm;
								if(system->surf_print_level == 5)
									surf_print = 1;
							} /* end beta_move */
							++am;
							if(system->surf_print_level == 4)
								surf_print = 1;
						} /* end alpha_move */
						++go;
						if(system->surf_print_level == 3)
							surf_print = 1;
					} /* end gamma_origin */
					++bo;
					if(system->surf_print_level == 2)
						surf_print = 1;
				} /* end beta_origin */
				++ao;
				if (system->surf_print_level == 1)
					surf_print = 1;
			} /* end alpha_origin */

			if(system->surf_decomp) {

				printf("%.5f %.5f %.5f %.5f\n", r, pe_es_avg, pe_rd_avg, pe_polar_avg);
				fflush(stdout);

			} else {

				printf("%.5f %.5f\n", r, pe_total_avg);
				fflush(stdout);
			}
		} /* end r */
	}

	return(0);
}