@@ -7,6 +7,7 @@ using namespace std;
77
88#define UNUSED (expr ) (void )(expr)
99
10+
1011namespace simple_physics_solver
1112{
1213 SimplePhysicsSolverConfig::SimplePhysicsSolverConfig (const double omega_e, const double omega_b,
@@ -48,22 +49,21 @@ namespace simple_physics_solver
4849 double * forces)
4950 {
5051 UNUSED (t);
51- cout << " SimplePhysicsSolver::evaluate_external_e_field(t=" << t << " )" << endl;
52+ // cout << "SimplePhysicsSolver::evaluate_external_e_field(t=" << t << ")" << endl;
5253 double pre_factor = (- config->epsilon ) * (config->omega_e * config->omega_e );
5354 double factor = double (0.0 );
5455 for (size_t i = 0 ; i < num_particles; ++i) {
55- cout << " particle " << i << endl;
56+ // cout << " particle " << i << endl;
5657 factor = pre_factor / (charges[i] / masses[i]);
57- // BUG!!!
58- cout << " position: " ;
59- internal::print_vec (positions + (i * DIM));
60- cout << endl << " factor: " << factor << endl;
58+ // cout << " position: ";
59+ // internal::print_vec(positions + (i * DIM));
60+ // cout << endl << " factor: " << factor << endl;
6161 internal::scale_mat_mul_vec (config->external_e_field_matrix , positions + (i * DIM), factor, forces + (i * DIM));
62- cout << " force: " ;
63- internal::print_vec (forces + (i * DIM));
64- cout << endl;
62+ // cout << " force: ";
63+ // internal::print_vec(forces + (i * DIM));
64+ // cout << endl;
6565 }
66- cout << " DONE SimplePhysicsSolver::evaluate_external_e_field(t=" << t << " )" << endl;
66+ // cout << "DONE SimplePhysicsSolver::evaluate_external_e_field(t=" << t << ")" << endl;
6767 }
6868
6969 void evaluate_internal_e_field (const double * positions, const double * charges, const double * masses,
@@ -72,48 +72,48 @@ namespace simple_physics_solver
7272 double * exyz, double * phis)
7373 {
7474 UNUSED (masses); UNUSED (t);
75- cout << " SimplePhysicsSolver::evaluate_internal_e_field(t=" << t << " )" << endl;
75+ // cout << "SimplePhysicsSolver::evaluate_internal_e_field(t=" << t << ")" << endl;
7676 double r = double (0.0 ),
7777 r3 = double (0.0 ),
7878 dist = double (0.0 );
7979
8080 // computing forces on particle i
8181 for (size_t i = 0 ; i < num_particles; ++i) {
82- cout << " particle " << i << endl;
82+ // cout << " particle " << i << endl;
8383
8484 // null result values
8585 phis[i] = double (0.0 );
8686 for (size_t d = 0 ; d < DIM; ++d) { exyz[i * DIM + d] = double (0.0 ); }
8787
8888 // effects of particle j on particle i
8989 for (size_t j = 0 ; j < num_particles; ++j) {
90- cout << " particle " << j << endl;
90+ // cout << " particle " << j << endl;
9191 if (j == i) {
92- cout << " skipping" << endl;
92+ // cout << " skipping" << endl;
9393 continue ;
9494 }
9595 dist = double (0.0 );
9696 for (size_t d = 0 ; d < DIM; ++d) {
9797 dist += (positions[i * DIM + d] - positions[j * DIM + d]) * (positions[i * DIM + d] - positions[j * DIM + d]);
9898 }
99- cout << " dist = " << dist << endl;
99+ // cout << " dist = " << dist << endl;
100100 r = sqrt (dist * dist + config->sigma2 );
101- cout << " r = " << r << " (= sqrt(dist^2+" << config->sigma2 << " )" << endl;
101+ // cout << " r = " << r << " (= sqrt(dist^2+" << config->sigma2 << ")" << endl;
102102 phis[i] += charges[j] / r;
103103
104104 r3 = r * r * r;
105105 for (size_t d = 0 ; d < DIM; ++d) {
106106 exyz[i * DIM + d] += positions[j * DIM + d] / r3 * charges[j];
107- cout << " exyz[" << i * DIM + d << " ] += " << positions[j * DIM + d] << " / " << r3 << " * " << charges[j] << " (q) => " << exyz[i * DIM + d] << endl;
107+ // cout << " exyz[" << i * DIM + d << "] += " << positions[j * DIM + d] << " / " << r3 << " * " << charges[j] << "(q) => " << exyz[i * DIM + d] << endl;
108108 }
109109 }
110110
111- cout << " exyz = " ;
112- internal::print_vec (exyz+(i*DIM));
113- cout << endl
114- << " phi_i = " << phis[i] << endl;
111+ // cout << " exyz = ";
112+ // internal::print_vec(exyz+(i*DIM));
113+ // cout << endl
114+ // << " phi_i = " << phis[i] << endl;
115115 }
116- cout << " DONE SimplePhysicsSolver::evaluate_internal_e_field(t=" << t << " )" << endl;
116+ // cout << "DONE SimplePhysicsSolver::evaluate_internal_e_field(t=" << t << ")" << endl;
117117 }
118118
119119
@@ -122,22 +122,22 @@ namespace simple_physics_solver
122122 const SimplePhysicsSolverConfig* config,
123123 double * forces)
124124 {
125- cout << " SimplePhysicsSolver::evaluate_e_field(t=" << t << " )" << endl;
125+ // cout << "SimplePhysicsSolver::evaluate_e_field(t=" << t << ")" << endl;
126126 double * external = new double [num_particles * DIM];
127127 double * internal = new double [num_particles * DIM];
128128 double * phis = new double [num_particles];
129129 evaluate_external_e_field (positions, charges, masses, num_particles, t, config, external);
130130 evaluate_internal_e_field (positions, charges, masses, num_particles, t, config, internal, phis);
131- cout << " -> e_forces = [ " << endl;
131+ // cout << " -> e_forces = [ " << endl;
132132 for (size_t i = 0 ; i < num_particles; ++i) {
133- cout << " " ;
133+ // cout << " ";
134134 for (size_t d = 0 ; d < DIM; ++d) {
135135 forces[i * DIM + d] = external[i * DIM + d] + internal[i * DIM + d];
136136 }
137- internal::print_vec (forces + (i * DIM));
138- cout << endl;
137+ // internal::print_vec(forces + (i * DIM));
138+ // cout << endl;
139139 }
140- cout << " ]" << endl;
140+ // cout << " ]" << endl;
141141 delete[] external;
142142 delete[] internal;
143143 delete[] phis;
@@ -178,7 +178,7 @@ namespace simple_physics_solver
178178 const size_t num_particles, const double t,
179179 const SimplePhysicsSolverConfig* config)
180180 {
181- cout << " SimplePhysicsSolver::compute_energy(t=" << t << " )" << endl;
181+ // cout << "SimplePhysicsSolver::compute_energy(t=" << t << ")" << endl;
182182 double e_kin = double (0.0 );
183183 double e_pot = double (0.0 );
184184
@@ -190,33 +190,33 @@ namespace simple_physics_solver
190190 evaluate_internal_e_field (positions, charges, masses, num_particles, t, config, exyz, phis);
191191
192192 for (size_t i = 0 ; i < num_particles; ++i) {
193- cout << " particle " << i << endl;
193+ // cout << " particle " << i << endl;
194194 // potential energy (induced by external electric field, position and internal electric field (i.e. phis))
195195 internal::scale_mat_mul_vec (config->external_e_field_matrix , positions + (i * DIM),
196196 (- config->epsilon * config->omega_e * config->omega_e / double (2.0 ) * (charges[i] / masses[i])),
197197 temp);
198198 e_pot += (charges[i] * phis[i]) - internal::scalar_prod (temp, positions + (i * DIM));
199- cout << " e_pot += " << charges[i] << " * " << phis[i] << " - <" ;
200- internal::print_vec (temp);
201- cout << " , " ;
202- internal::print_vec (positions + (i * DIM));
203- cout << " > (=" << internal::scalar_prod (temp, positions + (i * DIM)) << " )" << endl;
199+ // cout << " e_pot += " << charges[i] << " * " << phis[i] << " - <";
200+ // internal::print_vec(temp);
201+ // cout << ", ";
202+ // internal::print_vec(positions + (i * DIM));
203+ // cout << "> (=" << internal::scalar_prod(temp, positions + (i * DIM)) << ")" << endl;
204204
205205 // kinetic energy (induced by velocity)
206206 v2 = internal::scalar_prod (velocities + (i * DIM), velocities + (i * DIM));
207207 e_kin += masses[i] / double (2.0 ) * v2;
208- cout << " e_kin += " << masses[i] << " (m) / 2.0" << " * <" ;
209- internal::print_vec (velocities + (i * DIM));
210- cout << " , " ;
211- internal::print_vec (velocities + (i * DIM));
212- cout << " > (=" << v2 << " )" << endl;
208+ // cout << " e_kin += " << masses[i] << "(m) / 2.0" << " * <";
209+ // internal::print_vec(velocities + (i * DIM));
210+ // cout << " , ";
211+ // internal::print_vec(velocities + (i * DIM));
212+ // cout << "> (=" << v2 << ")" << endl;
213213 }
214214
215215 delete[] exyz;
216216 delete[] phis;
217217 delete[] temp;
218- cout << " -> energy = " << e_kin << " + " << e_pot << endl;
219- cout << " DONE SimplePhysicsSolver::compute_energy(t=" << t << " )" << endl;
218+ // cout << " -> energy = " << e_kin << " + " << e_pot << endl;
219+ // cout << "DONE SimplePhysicsSolver::compute_energy(t=" << t << ")" << endl;
220220 return e_kin + e_pot;
221221 }
222222
0 commit comments