Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix energy conservation #495

Merged
merged 3 commits into from
Feb 25, 2016

Conversation

unoebauer
Copy link
Contributor

As found by @chvogl and reported in issue #448, an inconsistency in the energy conservation calculation exists. Instead of the Doppler factor at the interaction location, the initial Doppler factor, determined at the beginning of the trajectory segment is used. For typical applications, the consequences of this inconsistency should be small (as discussed in #448). Nevertheless, this PR aims at fixing this inconsistency.

  • fix energy conservation, i.e. use Doppler factors at the interaction location
  • investigate consequences (check tardis_example)
  • decide whether move_packet should actually return the doppler factor
  • adjust and update tests

* whenever a packet Thomson scatters or performs a line scattering, the
  Doppler factor at the interaction location is used (instead of the
  Doppler factor at the beginning of the trajectory segment)
@unoebauer unoebauer added this to the v1.5 milestone Feb 24, 2016
@yeganer
Copy link
Contributor

yeganer commented Feb 24, 2016

@unoebauer When I first looked at the C code I was wondering why move_packed returned the doppler_factor.

My suggestion: add rpacket_get_doppler_factor(*rpacket)returning the dopplerfactor of the current packet ( current r, mu). I don't think we need that factor saved to rpacket. then any time we need the doppler factor we can just call that function and save it in a local variable.
If there are too many calls to rpacket_get_doppler_factor, maybe we should rename it to update_doppler_factor and then save the doppler_factor as a property of rpacket

@unoebauer
Copy link
Contributor Author

Fix does not seem to induce significant changes for standard setups:

spec_cmp

@unoebauer
Copy link
Contributor Author

@yeganer, @ssim, @wkerzendorf, @chvogl

Many tests had to be updated - for future references: we should write a script which recalculates all the data files once critical changes have been made within the Monte Carlo routine. Of course, before using these files, they should be carefully compared with the current ones. I have started a very crude version of such a script.

@yeganer
Copy link
Contributor

yeganer commented Feb 24, 2016

@unoebauer Last time we did this I advised against creating such a script because it could be used carelessly. But I guess with future slow tests coming we might need that.

@unoebauer
Copy link
Contributor Author

Well - true, there is a temptation to use it carelessly. But manually building all the data files is really painful!

@unoebauer
Copy link
Contributor Author

Ok - Travis is finally happy. Should this be merged @wkerzendorf, @yeganer?

It would be good if you, @ssim and @chvogl, could also have a careful look at it.

Before merging, I'll clean-up the commit history.

* Move packet no longer returns the Doppler factor since this
  functionality is no longer required
* temporarily deactivated test_move_packet in test_cmontecarlo.c
* marked it skipped due to bad design
* update reference data for tardis_full_test
* update reference data for simulation_test
* update reference data for plasma_full_test
dealloc_storage_model(&sm);
return res;
}
//double
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@unoebauer should we just delete these lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well - I wouldn't for now. Eventually, we want to test move_packet, just in a different way. I'd keep these lines as a reminder.

@yeganer
Copy link
Contributor

yeganer commented Feb 24, 2016

I think this is ready to get merged.

Regarding test_move_packet:
I think it's fine to have it in the c code. We could even uncomment it because the test is skipped anyway. Deleting the lines is dangerous because when the tests get an overhaul one could easily forget implementing this one.

@ssim
Copy link
Contributor

ssim commented Feb 24, 2016

I think that yes, I agree with this fix. I wonder how it came about that there was an error here but I think that yes, it is was wrong. It would have been correct if the Dopper factor were re-calculated at the end of "move packet" before being returned, but that was not being done. This seems like the right fix to me.

wkerzendorf added a commit that referenced this pull request Feb 25, 2016
@wkerzendorf wkerzendorf merged commit ce93d78 into tardis-sn:master Feb 25, 2016
sooryan pushed a commit to sooryan/tardis that referenced this pull request Mar 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants