Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // calculating the integral each timestep
- double integral = 0.0;
- double E_n = 1.5 * T_n;
- // creating histogram each timestep
- for (int i = 0; i < n_e; i++){
- int bin = (int)( (electrons[i].energy - Emin)/bin_width );
- if (bin >=0 && bin < N)
- histo_maxwell[bin]++;
- }
- for (int i = 0; i < N; i++){
- double bin_center = Emin + (i + 0.5) * bin_width;
- integral+= (bin_center - E_n)*elastic_vec[i]*sqrt(bin_center)*( static_cast<double>(histo_maxwell[i])/(electrons.size()*bin_width) ) * delta * (N_He/Volume) * sqrt(2*q/m_e) * bin_width; //
- }
- E_mean -= integral*dt;
- file10 << t*dt << " " << E_mean << "\n";
- for (int i = 0; i < N; i++){
- histo_maxwell[i] = 0;
- }
- // calculating mean energy
- double total_energy = 0.0;
- for (const auto& e : electrons) total_energy += e.energy;
- double mean_energy = total_energy / n_e;
- file8 << t*dt << " " << mean_energy << "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement