I have approximations for a series of correlation functions that are described by two variables, theta
and Dw
. The correlation functions are incorporated into a larger equation, where there are 4 additional variables. These variables are: gyroI
, gyroS
, r
, and dec
. These 4 variables are all measurable quantities that I have. I wrote this to a function and plotted the dependence of the single output value as a dependence of theta
and Dw
.
import numpy as np
import matplotlib.pyplot as plt
N = 100
theta = np.linspace(np.pi/180, np.pi/30, N)
Dw = np.linspace(10, 200, N*2)
theta, Dw = np.meshgrid(theta, Dw)
def relax(theta, Dw, gyroI, gyroS, dist, decI):
c = np.cos(theta)
X0 = (1/20)*(c*(1+c)*(9*(c**2)-1)+4)-((1/4)*(c**2)*((1+c)**2))
X1 = (1/10)*(1-c)*((2+c)*(1+(3*c**2))+(3*c))
X2 = (1/40)*((1-c)**2)*((3*c**2)+(9*c)+8)
t0 = (1/(Dw*X0))*((((c**2)*((1+c)**2))/(2*(c-1)))*(np.log(((1+c)/2)-((1-c)/2)))+(((1-c)*(2-c-(9*c**2)-(7*c**3)))/60))
t1 = (((1-c)**2)*(9+(32*c)+(44*c**2)+(20*c**3)))/(120*Dw*X1)
t2 = (((1-c)**3)*(8+(12*c)+(5*c**2)))/(240*Dw*X2)
mu = (2*np.pi*122000)
R2 = ((mu)*((gyroS/gyroI)/(dist**3))**2)*(((2*X2*t2)/(5*(1+(decI**2)*(t2**2))))+((2*X1*t1)/(5*(1+(decI**2)*(t1**2))))+((X0*t0)/(5*(1+(decI**2)*(t0**2)))))
return R2
Z = 1/relax(theta, Dw, 599.7690768e6, 60.825978e6, 1.04, 92000.0)/1e3
cmap = plt.get_cmap('jet_r')
CT =plt.contourf(np.degrees(theta), Dw, np.log10(Z), levels= 15 ,cmap=cmap)
plt.colorbar(CT)
plt.xlabel('theta')
plt.ylabel('Dw')
plt.show()
Which produces the plot:
What I would like to find is a way to have a function that takes in a single scalar value (in this case a single value of R2
) and returns all values of theta
and Dw
that describe that value. Such that I am able effectively find all values that describe the dashed lines in the second figure within a range and resolution that I can define.
example plot 2 - dashed values of interest:
How can I leverage python to use the defined equations in the function for a single value of R2 and return the corresponding theta and Dw values that describe it?