Beispiel #1
0
uint32_t atom_index_by_id(const char *id)
{
    atom_def_t *atom;
    uint32_t    index;

    if ((atom = find_atom_by_id(id)) != NULL)
        index = atom->index;
    else
        index = ATOM_INVALID_INDEX;
   
    return index;
}
Beispiel #2
0
uint32_t atom_create(const char *id, const char *name)
{
    atom_def_t *atom;
    uint32_t    index = ATOM_INVALID_INDEX;

    if (id && name) {
        if ((atom = find_atom_by_id(id)) == NULL) {
            if ((atom = create_atom(id, name)) != NULL)
                index = atom->index;
        }
        else {
            if (!strcmp(name, atom->name))
                index = atom->index;
            else {
                OHM_ERROR("videoep: incosistent multiple definition of "
                          "atom '%s' ('%s' vs. '%s')", id, name, atom->name);
            }
        }
    }

    return index;
}
Beispiel #3
0
int surface_dimer_parameters(system_t *system, param_g *params) {

	int i = 0; // generic counter
	
	molecule_t *molecule_ptr;
	atom_t *atom_ptr;
	param_t *param_ptr;
	
	// Default bond partner for atoms without explicit site neighbor
	atom_t *origin = calloc( sizeof(atom_t), 1 ); // calloc sets pos[] fields all to 0
	memnullcheck( origin, sizeof(atom_t), __LINE__-1, __FILE__);

	system->polar_damp = params->alpha;

	for (molecule_ptr = system->molecules; molecule_ptr; molecule_ptr = molecule_ptr->next) {
	
		for (atom_ptr = molecule_ptr->atoms; atom_ptr; atom_ptr = atom_ptr->next) {
	
			for (param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) {
	
				if( !strcasecmp( param_ptr->atomtype, atom_ptr->atomtype )) {

					atom_ptr->charge  = param_ptr->charge;
					atom_ptr->epsilon = param_ptr->epsilon;
					atom_ptr->sigma   = param_ptr->sigma;
					atom_ptr->omega   = param_ptr->omega;
					atom_ptr->polarizability = param_ptr->pol;
					atom_ptr->c6 = param_ptr->c6;
					atom_ptr->c8 = param_ptr->c8;
					atom_ptr->c10 = param_ptr->c10;

					double perturbation_vector[3];

					// Find the the atom that defines the bond axis and store for easy reference
					atom_t *snPtr = 0;
					if( atom_ptr->site_neighbor_id == 0 )
						snPtr = origin;
					else {
						snPtr = find_atom_by_id( system, atom_ptr->site_neighbor_id );
						if( !snPtr ) {
							snPtr = origin;
							printf( "\n*** WARNING ***\n" );
							printf( "Bonding partner for atom %d not found ",      atom_ptr->bond_id );
							printf( "--> %d, possibly invalid. Using origin.\n\n", atom_ptr->site_neighbor_id );
						}
					}

					// Generate the vector along which the dr perturbations will occur
					for (i = 0; i < 3; i++)
						perturbation_vector[i] = atom_ptr->pos[i] - snPtr->pos[i];

					// Determine how much the bond vector should be scaled to increase the length by dr.
					double scale = find_scale_factor(perturbation_vector[0], perturbation_vector[1], perturbation_vector[2], param_ptr->dr);
					
					// Scale the perturbation vector
					for (i = 0; i < 3; i++)
						perturbation_vector[i] *= scale;
					
					// Add the vector back to the bond partner coordinates to get the new position.
					for (i = 0; i < 3; i++)
						atom_ptr->pos[i] = snPtr->pos[i] + perturbation_vector[i];

				}
			} // for param_ptr
		} // for atom_ptr
	} // for molecule_ptr

	free(origin);

	return (0);
}