Skip to content

Commit

Permalink
added more complex geometry for Clebsch coordinate calculations
Browse files Browse the repository at this point in the history
Geometry used was taken from boutproject/BOUT-dev#2207
  • Loading branch information
pollypparrot authored Jul 12, 2023
1 parent 52e36d4 commit 0b5b598
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions MasterclassCode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 20,
"id": "0f97fbe7",
"metadata": {
"scrolled": true
Expand Down Expand Up @@ -1826,7 +1826,7 @@
{
"data": {
"text/latex": [
"$\\displaystyle Jacobian = \\frac{h_{\\theta}}{B_{pol}} = h_{\\theta} x$"
"$\\displaystyle Jacobian = \\frac{h_{\\theta}}{B_{pol}} = 0.0081 \\left(0.111111111111111 x + 1\\right)^{2}$"
],
"text/plain": [
"<IPython.core.display.Math object>"
Expand All @@ -1838,7 +1838,7 @@
{
"data": {
"text/latex": [
"$\\displaystyle Bpol = \\frac{1}{x}$"
"$\\displaystyle Bpol = \\frac{1}{0.01 x + 0.09}$"
],
"text/plain": [
"<IPython.core.display.Math object>"
Expand All @@ -1850,7 +1850,7 @@
{
"data": {
"text/latex": [
"$\\displaystyle Btor = \\frac{1}{R}$"
"$\\displaystyle Btor = \\frac{1}{- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1}$"
],
"text/plain": [
"<IPython.core.display.Math object>"
Expand All @@ -1862,7 +1862,7 @@
{
"data": {
"text/latex": [
"$\\displaystyle Bxy = \\sqrt{\\frac{1}{x^{2}} + \\frac{1}{R^{2}}}$"
"$\\displaystyle Bxy = 11.1111111111111 \\sqrt{\\frac{0.0081}{\\left(- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1\\right)^{2}} + \\frac{1}{\\left(0.111111111111111 x + 1\\right)^{2}}}$"
],
"text/plain": [
"<IPython.core.display.Math object>"
Expand All @@ -1874,7 +1874,7 @@
{
"data": {
"text/latex": [
"$\\displaystyle gxx = \\frac{R^{2}}{x^{2}}$"
"$\\displaystyle gxx = \\frac{123.456790123457 \\left(- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1\\right)^{2}}{\\left(0.111111111111111 x + 1\\right)^{2}}$"
],
"text/plain": [
"<IPython.core.display.Math object>"
Expand All @@ -1886,7 +1886,7 @@
{
"data": {
"text/latex": [
"$\\displaystyle gzz = \\frac{I^{2} R^{2}}{x^{2}} + \\frac{x^{2} \\left(\\frac{1}{x^{2}} + \\frac{1}{R^{2}}\\right)}{R^{2}}$"
"$\\displaystyle gzz = \\frac{123.456790123457 I^{2} \\left(- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1\\right)^{2}}{\\left(0.111111111111111 x + 1\\right)^{2}} + \\frac{0.0081 \\left(0.111111111111111 x + 1\\right)^{2} \\left(\\frac{1.0}{\\left(- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1\\right)^{2}} + \\frac{123.456790123457}{\\left(0.111111111111111 x + 1\\right)^{2}}\\right)}{\\left(- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1\\right)^{2}}$"
],
"text/plain": [
"<IPython.core.display.Math object>"
Expand Down Expand Up @@ -1924,7 +1924,7 @@
{
"data": {
"text/latex": [
"$\\displaystyle b = z^{2} + 2 \\left(\\frac{I^{2} R^{2}}{x^{2}} + \\frac{x^{2} \\left(\\frac{1}{x^{2}} + \\frac{1}{R^{2}}\\right)}{R^{2}}\\right) \\left(x + y + \\sin{\\left(2 \\pi z \\right)}\\right)$"
"$\\displaystyle b = z^{2} + 2.0 \\left(\\frac{123.456790123457 I^{2} \\left(- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1\\right)^{2}}{\\left(0.111111111111111 x + 1\\right)^{2}} + \\frac{0.0081 \\left(0.111111111111111 x + 1\\right)^{2} \\left(\\frac{1.0}{\\left(- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1\\right)^{2}} + \\frac{123.456790123457}{\\left(0.111111111111111 x + 1\\right)^{2}}\\right)}{\\left(- \\left(0.01 x + 0.09\\right) \\cos{\\left(y \\right)} + 1\\right)^{2}}\\right) \\left(x + y + \\sin{\\left(2 \\pi z \\right)}\\right)$"
],
"text/plain": [
"<IPython.core.display.Math object>"
Expand All @@ -1938,7 +1938,7 @@
"output_type": "stream",
"text": [
"result that is copiable to c++ NOTE: change ** to pow(a,b) to avoid errors in c++\n",
"z**2 + 2*(I**2*R**2/x**2 + x**2*(x**(-2) + R**(-2))/R**2)*(x + y + sin(2*pi*z))\n",
"z**2 + 2.0*(123.456790123457*I**2*(-(0.01*x + 0.09)*cos(y) + 1)**2/(0.111111111111111*x + 1)**2 + 0.0081*(0.111111111111111*x + 1)**2*(1.0/(-(0.01*x + 0.09)*cos(y) + 1)**2 + 123.456790123457/(0.111111111111111*x + 1)**2)/(-(0.01*x + 0.09)*cos(y) + 1)**2)*(x + y + sin(2*pi*z))\n",
"\n"
]
}
Expand All @@ -1963,11 +1963,16 @@
"#write Jacobian, metric tensors and functions for B and R\n",
"#start with B functions as then, when the Jacobian and metric tensors are applied, the functions are subbed in.\n",
"\n",
"Bpol = 1/x\n",
"Btor = 1/R\n",
"eps =.1\n",
"r = eps*(0.9 +0.1*x)\n",
"theta = y-pi\n",
"Rxy = 1 + r*cos(theta)\n",
"h=r\n",
"Bpol = 1/r\n",
"Btor = 1/Rxy\n",
"Bxy = sqrt(Bpol**2 + Btor**2)\n",
"JClebsch = h/Bpol\n",
"clebschMetricTensor = [(R*Bpol)**2, 1/(h)**2,I**2*(R*Bpol)**2+Bxy**2/(R*Bpol)**2]\n",
"clebschMetricTensor = [(Rxy*Bpol)**2, 1/(h)**2,I**2*(Rxy*Bpol)**2+Bxy**2/(Rxy*Bpol)**2]\n",
"\n",
"A = x+y+sin(2*pi*z)\n",
"D = 1\n",
Expand Down

0 comments on commit 0b5b598

Please sign in to comment.