Logbook  (07-04-2025)
Static problems
exact_solution.hpp
1 /******************************************************************************
2  * Copyright (C) Siarhei Uzunbajakau, 2023.
3  *
4  * This program is free software. You can use, modify, and redistribute it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation, either version 3 or (at your option) any later version.
7  * This program is distributed without any warranty.
8  *
9  * Refer to COPYING.LESSER for more details.
10  ******************************************************************************/
11 
12 #ifndef ExactSolutionSSOLIIIAXI_H__
13 #define ExactSolutionSSOLIIIAXI_H__
14 
15 #include <deal.II/base/function.h>
16 #include <deal.II/base/tensor.h>
17 
18 #include <deal.II/lac/vector.h>
19 
20 #include <cmath>
21 
22 #include "constants.hpp"
23 #include "settings.hpp"
24 
25 using namespace dealii;
26 
27 inline Tensor<1, 3>
28 volume_free_current_density(double x,
29  double y,
30  double z,
31  double J_0,
32  double a,
33  double b)
34 {
35  Tensor<1, 3> J;
36  double r;
37 
38  r = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
39 
40  if ((r > a) && (r < b)) {
41  J[0] = -J_0 * y;
42  J[1] = J_0 * x;
43  J[2] = 0.0;
44  } else {
45  J[0] = 0.0;
46  J[1] = 0.0;
47  J[2] = 0.0;
48  }
49 
50  return J;
51 }
52 
53 inline Tensor<1, 3>
54 magnetic_field_coil(double x,
55  double y,
56  double z,
57  double J_0,
58  double mu_0,
59  double a,
60  double b)
61 {
62  double cos_theta;
63  double sin_theta;
64 
65  double cos_phi;
66  double sin_phi;
67 
68  Tensor<1, 3> r_hat;
69  Tensor<1, 3> theta_hat;
70 
71  Tensor<1, 3> F1;
72  Tensor<1, 3> F2;
73  Tensor<1, 3> B;
74 
75  double r;
76 
77  r = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
78 
79  cos_theta = z / r;
80  sin_theta = sqrt(pow(x, 2) + pow(y, 2)) / r;
81 
82  cos_phi = x / sqrt(pow(x, 2) + pow(y, 2));
83  sin_phi = y / sqrt(pow(x, 2) + pow(y, 2));
84 
85  r_hat[0] = x / r;
86  r_hat[1] = y / r;
87  r_hat[2] = z / r;
88 
89  theta_hat[0] = cos_theta * cos_phi;
90  theta_hat[1] = cos_theta * sin_phi;
91  theta_hat[2] = -sin_theta;
92 
93  F1 = (2.0 / 3.0) * mu_0 * J_0 * (cos_theta * r_hat - sin_theta * theta_hat);
94  F2 = (2.0 / 3.0) * mu_0 * J_0 *
95  (cos_theta * r_hat + 0.5 * sin_theta * theta_hat) / pow(r, 3);
96 
97  if (r < a) {
98  B = 0.5 * (pow(b, 2) - pow(a, 2)) * F1;
99  } else if (r > b) {
100  B = 0.2 * (pow(b, 5) - pow(a, 5)) * F2;
101  } else {
102  B = 0.5 * (pow(b, 2) - pow(r, 2)) * F1 + 0.2 * (pow(r, 5) - pow(a, 5)) * F2;
103  }
104 
105  return B;
106 }
107 
108 inline Tensor<1, 3>
109 magnetic_field_core(double x,
110  double y,
111  double z,
112  double H_0,
113  double mur,
114  double mu0,
115  double a,
116  double b)
117 {
118  double a3 = std::pow(a, 3);
119  double b3 = std::pow(b, 3);
120 
121  double OMEGA = ((mur - 1.0) / (mur + 2.0)) * (a3 / b3);
122  double gamma_1 =
123  (-3.0 * b3 * H_0 * OMEGA) / ((2.0 * mur + 1.0) - 2.0 * (mur - 1.0) * OMEGA);
124  double beta_1 = ((2.0 * mur + 1.0) * gamma_1) / ((mur - 1.0) * a3);
125  double alpha_1 = (-b3 * H_0 + 2.0 * mur * gamma_1 - mur * b3 * beta_1) / 2.0;
126  double delta_1 = (mur * a3 * beta_1 - 2.0 * mur * gamma_1) / a3;
127 
128  double r = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
129  double r3 = std::pow(r, 3.0);
130  double zz = -3.0 * z * z / std::pow(r, 5.0);
131  double xz = -3.0 * x * z / std::pow(r, 5.0);
132  double yz = -3.0 * y * z / std::pow(r, 5.0);
133 
134  double mu;
135 
136  Tensor<1, 3> grad_psi;
137  Tensor<1, 3> B;
138  Tensor<1, 3> Happl;
139 
140  if (r < a) {
141  grad_psi[0] = 0.0;
142  grad_psi[1] = 0.0;
143  grad_psi[2] = delta_1;
144  mu = mu0;
145  } else if (r > b) {
146  grad_psi[0] = alpha_1 * xz;
147  grad_psi[1] = alpha_1 * yz;
148  grad_psi[2] = -H_0 + alpha_1 / r3 + alpha_1 * zz;
149  mu = mu0;
150  } else {
151  grad_psi[0] = gamma_1 * xz;
152  grad_psi[1] = gamma_1 * yz;
153  grad_psi[2] = beta_1 + gamma_1 / r3 + gamma_1 * zz;
154  mu = mur * mu0;
155  }
156 
157  Happl[0] = 0.0;
158  Happl[1] = 0.0;
159  Happl[2] = H_0;
160 
161  B = -mu * grad_psi - mu0 * Happl;
162 
163  return B;
164 }
165 
172  : public Function<2>
173  , public SettingsSSOLIIIAXI
174 {
175 public:
177  : Function<2>(2)
178  , B_0(2.0 * mu_0 * K_0 / 3.0)
179  {
180  }
181 
182  virtual void vector_value_list(
183  const std::vector<Point<2>>& r,
184  std::vector<Vector<double>>& values) const final;
185 
186 private:
187  const double B_0;
188 };
189 
196  : public Function<2>
197  , public SettingsSSOLIIIAXI
198 {
199 public:
201  : Function<2>(2)
202  {
203  }
204 
205  virtual void vector_value_list(
206  const std::vector<Point<2>>& r,
207  std::vector<Vector<double>>& values) const final;
208 
209 private:
211 };
212 
213 #endif
Describes exact solution, , of the Axisymmetric - thick spherical coil with magnetic core (ssol-iii-a...
Describes exact solution, , of the Axisymmetric - thick spherical coil with magnetic core (ssol-iii-a...
Global settings for the Axisymmetric - thick spherical coil with magnetic core (ssol-iii-axi/) numeri...
Definition: settings.hpp:26