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

Incorrect normalization when restarting spectral cycles #134

Closed
jhmatthews opened this issue Jan 15, 2015 · 5 comments
Closed

Incorrect normalization when restarting spectral cycles #134

jhmatthews opened this issue Jan 15, 2015 · 5 comments
Assignees
Labels
bug Bugs in the code high

Comments

@jhmatthews
Copy link
Collaborator

This is a problem of my own making, and I'm just flagging it here for documentation purposes, as it is present in e.g. Python 78b. A short time back (see agnwinds/python@ec8ccec) I changed get_matom_f() - the function which computes the macro-atom emissivities - so as to only recompute if geo,pcycles was 0. The reason being that one shouldn't have to go through the very lengthy process of computing macro-atom emissivities if you just want to restart a run to get better photon stats.

At the moment a restarted model with 500 spectral cycles has a very different continuum level (green is the restarted run, identical model and wind state):

screenshot 2015-01-15 17 07 36

I must have made a mistake somewhere, which is probably very simple and related to normalising the photon weights or similar. I will correct ASAP.

@jhmatthews jhmatthews added bug Bugs in the code high labels Jan 15, 2015
@jhmatthews jhmatthews self-assigned this Jan 15, 2015
@jhmatthews jhmatthews added this to the Before CV paper milestone Jan 15, 2015
@jhmatthews jhmatthews changed the title Problem Problem in get_matom_f when restarting spectral cycles: error in normalisation of spectrum / photon weights? Jan 15, 2015
@jhmatthews jhmatthews changed the title Problem in get_matom_f when restarting spectral cycles: error in normalisation of spectrum / photon weights? Problem in get_matom_f when restarting spectral cycles? Jan 15, 2015
@jhmatthews jhmatthews changed the title Problem in get_matom_f when restarting spectral cycles? Problem in get_matom_f when restarting spectral cycles Jan 16, 2015
@jhmatthews
Copy link
Collaborator Author

Ok, so this is nothing to do with macro-atoms or any of my recent changes. I ran a very very simple supernova model as far back as Python 77 with no wind or disk on, 1d, star only. Run 10 spectral cycles, restart running 50 spectral cycles with the same model. Outputs should be identical except the longer run should have better S/N. This is the result (green is restarted). Clearly we are failing to normalise properly in this case.

spec_old

Name of issue changed.

@jhmatthews
Copy link
Collaborator Author

In case it's not clear- this probably means that for all runs which restarted the spectral cycles to get better S/N, the spectrum will have incorrect total flux. This is not a problem in my CV runs where I deliberately did not restart.

@Higginbottom
Copy link
Collaborator

Uh oh!
I do not believe this will affect any of my published work either - I don't think I've ever restarted spectral cycles. It must be something pretty simple though....

@jhmatthews
Copy link
Collaborator Author

It is! The problem is just that when we read in a spec_save file we don't normalise the stuff we read in.

So for example, I am finding that if I run one model with 1 spectral cycles, then restart then run so that it does 5 cycles in total (4 more), the total flux is out by a factor of 1.8.. i.e we add 1 cycle of stuff to another 4 cycles, but the 4 cycles have a weight normalisation of (1/5) less than the spectrum we've read in.

The saved spectrum we read in should be multiplied by a factor f:

f = (cycles in old pf file) / (cycles in new pf file)

That was explained terribly but you get the idea. simple change which I'll make when I get a minute.

@jhmatthews jhmatthews changed the title Problem in get_matom_f when restarting spectral cycles Incorrect normalization when restarting spectral cycles Jan 22, 2015
jhmatthews added a commit to jhmatthews/sirocco that referenced this issue Jan 23, 2015
@jhmatthews
Copy link
Collaborator Author

I've fixed this with a simple little function called spectrum_restart_renormalise() in commit agnwinds/python@3ec1dae

Also verified that it produces correct results when all of the extra cycles are completed, and also if the restarted run is interrupted before the end (i.e. it is normalised correctly each cycle). Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in the code high
Projects
None yet
Development

No branches or pull requests

2 participants