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

Error in InterpolatedDistribution #135

Closed
422314581 opened this issue Feb 10, 2023 · 11 comments · Fixed by #145
Closed

Error in InterpolatedDistribution #135

422314581 opened this issue Feb 10, 2023 · 11 comments · Fixed by #145
Assignees

Comments

@422314581
Copy link

Hello, when I use InterpolatedDistribution, there was a problem

6ADD06A7-F45B-4495-B56C-4733A3BDC02D

@cosimoNigro
Copy link
Owner

cosimoNigro commented Feb 11, 2023

Hi @422314581, thanks for reporting this, I will fix it soon!
It was a bit stupid from my side, but after implementing the interpolated particle distribution I never tried to import it from a Blob or compute its output with a radiative process 😅, so thanks for spotting this.

@cosimoNigro
Copy link
Owner

cosimoNigro commented Feb 13, 2023

I think the easiest solution would be to implement a sinlge parameter, an amplitude or norm, multiplying the interpolated distribution. This can be set to 1 by default and, for example, varied in a fit.

@422314581 would you have an example of an electron distribution you are trying to interpolate that you could share with us? I guess you are using the output of some time-dependent code.
We could use it for these tests, instead of interpolating power-law distributions as we already do.
I think it would be very useful.

@422314581
Copy link
Author

Yes, you are right. I want the injection function of the electrons to determine the stationary stationary of electrons. like thisimage

B = 1.8 * u.G
B1 = 1.8
R_b = 2.8e15 * u.cm
R_b1 = 2.8e15

u_b = B12/(8np.pi)
r_b = 3
m_e*c
2/(4sigma_Tu_bR_b)
r_b = 3
9.1093837015e-2829979245800.0**2/(46.6524587321000005e-25u_bR_b1)
t_ad = R_b1/29979245800.0

def Q_e(gamma):
return 8.8 * gamma**(-2)np.e*(-gamma/1.8e4)np.e*(r_b/gamma)
def Q1(gamma):
return si.quad(Q_e,gamma,np.inf)[0]
def N(gamma):
return np.e**(-r_b/gamma) * r_b*t_ad /gamma**2 * Q1(gamma)
gamma_min1 = 1.40e+03
gamma_max = 5.00e+04
Gma = np.logspace(np.log10(gamma_min1), np.log10(gamma_max), 100)

Gma = [1400.0000000000005, 1451.4875266914864, 1504.868600100691, 1560.2128588255935, 1617.5925025492952, 1677.082386228548, 1738.7601177462361, 1802.7061591552008, 1869.0039316454931, 1937.7399243719876, 2009.0038072843165, 2082.8885481063508, 2159.490533617791, 2238.9096953961175, 2321.2496401829276, 2406.617785044728, 2495.12549750451, 2586.8882408269174, 2682.0257246465367, 2780.6620611358153, 2882.9259269163385, 2988.9507309246824, 3098.8747884518402, 3212.8415015832625, 3330.9995462748925, 3453.5030663092894, 3580.5118743848093, 3712.1916606002164, 3848.7142086066915, 3990.2576197092185, 4137.006545209707, 4289.152427294947, 4446.893748783661, 4610.436292058447, 4779.993407520415, 4955.786291916725, 5138.0442769041265, 5327.005128224939, 5522.91535588577, 5726.030535743617, 5936.615642918876, 6154.945397470217, 6381.304622782279, 6615.9886171337175, 6859.303538930317, 7111.566806105801, 7373.107510211271, 7644.266845733555, 7925.398555202518, 8216.869390667984, 8519.05959214832, 8832.363383674818, 9157.189487579002, 9493.9616576938, 9843.119232164136, 10205.117706588084, 10580.429328236447, 10969.5437121257, 11372.968479748195, 11791.229921292812, 12224.873682219963, 12674.465475086636, 13140.591817550094, 13623.860797512973, 14124.902866408, 14644.371661657162, 15182.944859378313, 15741.325058451597, 16320.240697099014, 16920.44700317284, 17542.726979392653, 18187.89242481617, 18856.784993876598, 19550.27729436791, 20269.274025810562, 21014.71315968268, 21787.56716305631, 22588.844267235214, 23419.589783048803, 24280.88746451912, 25173.86092267792, 26099.675091380926, 27059.53774702843, 28054.701084178057, 29086.463349101767, 30156.170533421686, 31265.21813003065, 32415.05295359142, 33607.17502798711, 34843.13954318634, 36124.55888407561, 37453.10473390561, 38830.51025509559, 40258.57235024077, 41739.1540062723, 43274.186724828, 44865.673042004375, 46515.68914077701, 48226.387559497445, 49999.99999999999]

n1 = [400.03038267515564, 364.4407824122864, 331.7536549049479, 301.7577319411341, 274.2549764294827, 249.05987916071075, 225.99879682887925, 204.90932616948302, 185.63970992703895, 168.04827112329076, 152.00287275998733, 137.38040066101476, 124.06626764274444, 111.953937605043, 100.94446846566291, 90.94607312514962, 81.87369785567016, 73.64861766284237, 66.19804828205453, 59.4547745467929, 53.3567949125473, 47.846981941752325, 42.87275855815742, 38.385789867597346, 34.341690320336596, 30.69974596137393, 27.42265148222659, 24.476261752867558, 21.829357478073774, 19.453424589126513, 17.322446951484054, 15.412711941978113, 13.702628426022159, 12.172556646503955, 10.804649521591267, 9.582704838579074, 8.492027825006703, 7.519303576343261, 6.6524788212870245, 5.880652510815274, 5.193974725194965, 4.583553403851673, 4.041368415924141, 3.560192504143148, 3.1335186510214883, 2.755493433901441, 2.4208559538781858, 2.1248819427261334, 1.8633326714552045, 1.6324083037949515, 1.4287053575543402, 1.2491779562674181, 1.0911025726683925, 0.9520459842251976, 0.8298361791012582, 0.7225359684328713, 0.6284190776442038, 0.5459485056288753, 0.4737569559752147, 0.41062915898336444, 0.35548591700781523, 0.30736971865954665, 0.26543177962583914, 0.22892037932750542, 0.19717037335224352, 0.1695937716026891, 0.14567128140525204, 0.12494472347009085, 0.10701023660453353, 0.09151219449209418, 0.07813776469585754, 0.06661204634543931, 0.056693728776638246, 0.04817121872021901, 0.04085918852791465, 0.034595502402685045, 0.029238481697073434, 0.024664474085549424, 0.020765694830302293, 0.01744831146997509, 0.014630746090911651, 0.012242171912762051, 0.010221183255677287, 0.008514620074228674, 0.007076530161901148, 0.005867253866396372, 0.004852617725842891, 0.004003224853869804, 0.0032938311808845986, 0.0027027978122132145, 0.0022116108024919615, 0.0018044605803757767, 0.0014678740979228032, 0.0011903935337989687, 0.0009622960568334191, 0.0007753497638635886, 0.0006226014500065597, 0.0004981923566509282, 0.00039719847819719145, 0.0003154923979911541] * u.Unit("cm-3")

@422314581
Copy link
Author

@cosimoNigro Thank you for your help

@422314581
Copy link
Author

Yes, you are right. I want the injection function of the electrons to determine the stationary stationary of electrons. like thisimage

B = 1.8 * u.G B1 = 1.8 R_b = 2.8e15 * u.cm R_b1 = 2.8e15

u_b = B12/(8_np.pi) r_b = 3_m_e*c2/(4_sigma_T_u_b_R_b) r_b = 3_9.1093837015e-28_29979245800.0**2/(4_6.6524587321000005e-25_u_b_R_b1) t_ad = R_b1/29979245800.0

def Q_e(gamma): return 8.8 * gamma**(-2)np.e(-gamma/1.8e4)np.e(r_b/gamma) def Q1(gamma): return si.quad(Q_e,gamma,np.inf)[0] def N(gamma): return np.e**(-r_b/gamma) * r_b*t_ad /gamma**2 * Q1(gamma) gamma_min1 = 1.40e+03 gamma_max = 5.00e+04 Gma = np.logspace(np.log10(gamma_min1), np.log10(gamma_max), 100)

Gma = [1400.0000000000005, 1451.4875266914864, 1504.868600100691, 1560.2128588255935, 1617.5925025492952, 1677.082386228548, 1738.7601177462361, 1802.7061591552008, 1869.0039316454931, 1937.7399243719876, 2009.0038072843165, 2082.8885481063508, 2159.490533617791, 2238.9096953961175, 2321.2496401829276, 2406.617785044728, 2495.12549750451, 2586.8882408269174, 2682.0257246465367, 2780.6620611358153, 2882.9259269163385, 2988.9507309246824, 3098.8747884518402, 3212.8415015832625, 3330.9995462748925, 3453.5030663092894, 3580.5118743848093, 3712.1916606002164, 3848.7142086066915, 3990.2576197092185, 4137.006545209707, 4289.152427294947, 4446.893748783661, 4610.436292058447, 4779.993407520415, 4955.786291916725, 5138.0442769041265, 5327.005128224939, 5522.91535588577, 5726.030535743617, 5936.615642918876, 6154.945397470217, 6381.304622782279, 6615.9886171337175, 6859.303538930317, 7111.566806105801, 7373.107510211271, 7644.266845733555, 7925.398555202518, 8216.869390667984, 8519.05959214832, 8832.363383674818, 9157.189487579002, 9493.9616576938, 9843.119232164136, 10205.117706588084, 10580.429328236447, 10969.5437121257, 11372.968479748195, 11791.229921292812, 12224.873682219963, 12674.465475086636, 13140.591817550094, 13623.860797512973, 14124.902866408, 14644.371661657162, 15182.944859378313, 15741.325058451597, 16320.240697099014, 16920.44700317284, 17542.726979392653, 18187.89242481617, 18856.784993876598, 19550.27729436791, 20269.274025810562, 21014.71315968268, 21787.56716305631, 22588.844267235214, 23419.589783048803, 24280.88746451912, 25173.86092267792, 26099.675091380926, 27059.53774702843, 28054.701084178057, 29086.463349101767, 30156.170533421686, 31265.21813003065, 32415.05295359142, 33607.17502798711, 34843.13954318634, 36124.55888407561, 37453.10473390561, 38830.51025509559, 40258.57235024077, 41739.1540062723, 43274.186724828, 44865.673042004375, 46515.68914077701, 48226.387559497445, 49999.99999999999]

n1 = [400.03038267515564, 364.4407824122864, 331.7536549049479, 301.7577319411341, 274.2549764294827, 249.05987916071075, 225.99879682887925, 204.90932616948302, 185.63970992703895, 168.04827112329076, 152.00287275998733, 137.38040066101476, 124.06626764274444, 111.953937605043, 100.94446846566291, 90.94607312514962, 81.87369785567016, 73.64861766284237, 66.19804828205453, 59.4547745467929, 53.3567949125473, 47.846981941752325, 42.87275855815742, 38.385789867597346, 34.341690320336596, 30.69974596137393, 27.42265148222659, 24.476261752867558, 21.829357478073774, 19.453424589126513, 17.322446951484054, 15.412711941978113, 13.702628426022159, 12.172556646503955, 10.804649521591267, 9.582704838579074, 8.492027825006703, 7.519303576343261, 6.6524788212870245, 5.880652510815274, 5.193974725194965, 4.583553403851673, 4.041368415924141, 3.560192504143148, 3.1335186510214883, 2.755493433901441, 2.4208559538781858, 2.1248819427261334, 1.8633326714552045, 1.6324083037949515, 1.4287053575543402, 1.2491779562674181, 1.0911025726683925, 0.9520459842251976, 0.8298361791012582, 0.7225359684328713, 0.6284190776442038, 0.5459485056288753, 0.4737569559752147, 0.41062915898336444, 0.35548591700781523, 0.30736971865954665, 0.26543177962583914, 0.22892037932750542, 0.19717037335224352, 0.1695937716026891, 0.14567128140525204, 0.12494472347009085, 0.10701023660453353, 0.09151219449209418, 0.07813776469585754, 0.06661204634543931, 0.056693728776638246, 0.04817121872021901, 0.04085918852791465, 0.034595502402685045, 0.029238481697073434, 0.024664474085549424, 0.020765694830302293, 0.01744831146997509, 0.014630746090911651, 0.012242171912762051, 0.010221183255677287, 0.008514620074228674, 0.007076530161901148, 0.005867253866396372, 0.004852617725842891, 0.004003224853869804, 0.0032938311808845986, 0.0027027978122132145, 0.0022116108024919615, 0.0018044605803757767, 0.0014678740979228032, 0.0011903935337989687, 0.0009622960568334191, 0.0007753497638635886, 0.0006226014500065597, 0.0004981923566509282, 0.00039719847819719145, 0.0003154923979911541] * u.Unit("cm-3")

I'm sorry my formatting is so messyimage

@cosimoNigro
Copy link
Owner

Hello @422314581,

I wanted to inform you that I am working on the fix, and at the same time, I am adding the analytical solution of the kinetic equation you pointed out (Eq. 8).

As soon as I pone the PR, I will point you to the branch.

@cosimoNigro
Copy link
Owner

cosimoNigro commented Mar 29, 2023

@422314581 why are you closing the issue?
Please do not do it, leave it open until this problem is fixed.

@cosimoNigro cosimoNigro reopened this Mar 29, 2023
@422314581
Copy link
Author

I'm sorry. I thought I just opened the question by mistake.

@FurenDeng
Copy link

btw, there is also no implement of evaluate_SSA_integrand in InterpolatedDistribution, and it raise exception when I want ssa in my SED

@cosimoNigro
Copy link
Owner

Thanks a lot @422314581 and @FurenDeng for reporting these issues.
I just opened #145 that should fix them.

@422314581 I am very sorry for the slow fix, I have been meaning for a while to introduce distributions that were actual solutions of the electrons kinetic equation (e.g. Eq. 8) - such that you wouldn't be forced to use the interpolation.
But it took a ling time, and I did not have a final result: I need more work.
I preferred to fix this specific issue for the time being.

@cosimoNigro cosimoNigro self-assigned this May 16, 2023
@cosimoNigro
Copy link
Owner

Hi @422314581, @FurenDeng, can you check with the dev version if your issues are fixed?
They should be.

Cheers.

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 a pull request may close this issue.

3 participants