...and so, at long last, I have solved the problem that was haunting me during this past month. My code is almost ready, and as far as I know, it is working properly. The main coding is ready, and with some other small changes in the last routine, everything will be working soon... I expect to have it ready by the end of this week.
During this past month I have barely touched the code. My adviser decided to give me some other task, and I was working with that for the past few weeks. Last week I have finished the task, and I have showed her my first results yesterday. She was quite excited about them, but they are only preliminary results. I still have to refine them. The task was to use the original program I am working with (prior to applying the changes I have done) to calculate the Lyman alpha line profile for TW Hya, a well known T Tauri star. The Lyman alpha line transition is a transition from the first energetic level to the second energetic level of the hydrogen atom. The photon generated in such a transition is in the ultraviolet part of the spectrum, and most of the contribution to the formation of this line comes from the magneto-accretion funnel, and the accretion shock region in the stellar photosphere. Enough to talk about that... I don't think anyone but me (and the people who work with me) is really interested in knowing more about that anyway... (But if anybody has any question about it, I can try to answer... :P)
So, Monday I gathered all my courage and started to figure out the problem in the code again. My mind was much more calm than when I last tried to work with that, some weeks ago. I decided in my mind that my deadline to finish this was this week, and so I opened the code, took a deep breath, and started to debug it, again... Running the program many times, looking the output files, searching and seeking the errors from one point to the other point of the code, until finding the very routine that was the source of the error or errors as I came to discover moments later.
Looking in a more detailed way at the output files, I have found something that I was not expecting. An error in the density values that I have not seen before. The code was having problems in "remembering" where some points really were. If the point is in the magneto-accretion funnel region, the density is calculated using one law, but if it is in the diskwind region, the density was calculated using another law. The problem was that the ONE code line, that was "remembering" the code where each of the points were, was misplaced and then the code was a little confused about the whereabouts of each point, and as such the densities were not correct everywhere. The error was corrected, the program ran, the densities were all corrected this time, BUT the end results were still wrong...
More work... more debugging... insanity taking over my mind again... The Cube... insomnia...
Then today, after a good night of sleep, and after arriving very late at my office, I started the work again. Seeking the errors through the code, from one variable to the previous erroneous one. After tracing back the error through a lot of variables, I have finally discovered that the source of my nightmares was in an interpolation routine. I have changed that routine a couple of months ago, but I have failed to notice a missing point there, and the thing that I have forgotten to change was the source of all my problems. With the previous line of code the program was looking for something like the "j+1" component of a vector-variable that had only a "j" number of components. And so the "j+1" component that was being read somewhere by the program was a random value coming from some unknown and sinister part of the memory (it is usually the next value in the memory block after where the vector-variable was stored). And that random value was affecting all my calculations, spreading the error throughout the other values like an infectious disease. Something that should be positive, had random negative values. Values that should be as low as zero, were acquiring values than a googol (not kidding here, some values were around the order of 1.e+290). And some other strange behavorial problems...
I changed that line and now everything is working properly. The output values for the source function and the average line intensities at each point in the system are being calculated correctly. Next step is to change the program that calculates the line profiles. No more hautings...
At least some good news concerning my work...
1 comment:
Cara, precisa ver a maquina que chegou ontem aqui. Eu e Chico demoramos semanas pra configurar e finalmente ela chegou.
Intel Core2 Quad, 2 GB de DDR, 320GB de disco, Nvidia GT8500, um puta gabinete e uma tela LC de 22 polegadas widescreen.
Bom demais.
Bom saber que o codigo comecou a funcionar, foda essas falhas de programacao tipo j+1 que deveria ser j.
Forca ai.
Post a Comment