I don't belive it, this was the largest change in the code ever made and
it is compiling now.
Now, I have to test, clean the code, change the examples and update the
documentation...
I need to make a common module for mesh, many functions for elements are
shared.
Also, try to reduce the 'select type' statements, but I don't know
enough Fortran for it.
It is now complete and working. I also added some minor improvements to moduleMesh.f90 using 'associate' to practice.
I noticed there are a lot of things (allocating K, for example) that are common for all meshes and should be moved to a general module.
I should've commited before, but I wanted to make things compile.
The big change is that I've added a global time step so the parameter
does not need to be passed in each function. This is useful as we are
moving towards using time profiles for boundary conditions and injection
of particles (not in this branch, but in the future and the procedure
will be quite similar)
I made some small changes to how things are calculated.
I have also discovered that the issue with different density when
changing injection is not related with the node volume but with the way
injection is carried out. When loading particles from a file, all
provide the same density regardless the cell (node) volume.
I am doing testing in 2DCart as it is easier to set up.
So now each edge has the same number of particles and the weight of each
particle is calculated based on the surface of each edge compared to the
total one.
Only in 2DCyl, still to extend to other geometries.
Not perfect constant density, but the issue might be the node volume.
Fixing an issue with reading tables led me to other issues with
collisions that I think are fixed right now. I am testing with the 1D
ionization model for ALPHIE and things seems to be working properly.
Coulomb scattering is now fully conservative thanks to the method in
lemos2009small.
The trick was to conserve the momentum and energy of ALL particles
involved in the scattering in each cell.
The substeps in Coulomb collisions have been removed as they are no
longer necessary.
Still some issues with e-i, but I don't know right now.
In an attempt to make the operator fully conservarive I have combined ij
and ji collisions (when i/=j).
Now the matter is to find a way that makes this conserve momentum and
energy for intraspecies.
Now per each Coulomb collision process there is the possibility to do
sub-steps. This helps in improving accuracy without reducing the time
step of the problem.
There was an issue with the calculation of theta and phi for the
rotation from W to C. This was causing some velocities not being
correct.
Now the angles are properly computed. Still unsure about the e-i
collisions as they seem to be quite small. Probably a numerical issue
with the mass ratios still exists.
The code is still not fully conservative in intra-species collisions
(small error) but at least now is working.
I have to test species with different weight.
I have to implement a fully conservation for intra-species.
I had to go back to sherlock2008montecarlo to properly understand the
change in frame of reference and how to translate that into the code.
The language there is clear and understandable for a dumb person like
me.
Now I have a Coulomb linear operator that at least works.
However, still not fully 100% conservative, need to fix this with a
correction for intra-species collisions.
I skip gym today because I was unable to focus on other things than
this.
I was having tones of issues with the previous implementation. I think
the problem was the velocity vector and how it was returning to the
normal reference frame.
I hope this new implementation works better.
I found no way to ensure conservation in the linear Coulomb operator.
Thus, now two collisions have to be declared if sp_i /= sp_j: collision
ij and collision ji.
This does not conserve energy so please use under your own risk, like
everything else.
Still, I think something is wrong with this implementation and I'm
really tired.
After fixing all possible divisions by zero I was able to find in the
Coulomb collision I think that this is a first working implementation of
a Coulomb operator based on moments.
Still to test a few things, modify the manual but I would say that I'm
satisfiyed right now. This operator won't be used that often but maybe
improving efficiency is still needed.
In the future a binary operator is required to be able to study cases
out of Maxwellian equilibrium.
When the relative velocity between a charged particle and the background
for Coulomb collisions (W in the code) was low, there was a
segmentation fault. This is fixed now as if the norm of the relative
velocity (normW) in the code is too low, no collision is applied.
I am doing a trick in which I ensure that energy is conserved for
Coulomb collisions. This was not happening and what an issue for
different mass ratios. Still, this can cause an issue on getting the
right relaxation rates, still necessary to check it.
First attemp for Coulomb collisions based on the moments distribtuions.
Still the method is not done and far from being complete but input
options and basic math are implemented.
Probes are now written at the 0 iteration.
Additionally, and this shouldn't be done, some small changes to the quad
elements. This should be done in a separate commit, but I'm lazy.
Due to a high convergence value (1.0e-2) in phy2logQuad (variable conv),
particles were being stuck in some elements, reaching a segmentation
fault. The new limit (1.0e-4) should avoid this.