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 ExactSolutionsSSOLIII_H__
13 #define ExactSolutionsSSOLIII_H__
14 
15 #include "constants.hpp"
16 #include "settings.hpp"
17 #include <deal.II/base/function.h>
18 #include <deal.II/lac/vector.h>
19 
20 #include <cmath>
21 
22 using namespace dealii;
23 
24 inline Tensor<1, 3>
25 volume_free_current_density(double x,
26  double y,
27  double z,
28  double K_0,
29  double a,
30  double b)
31 {
32  Tensor<1, 3> J;
33  double r;
34 
35  r = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
36 
37  if ((r > a) && (r < b)) {
38  J[0] = -K_0 * y;
39  J[1] = K_0 * x;
40  J[2] = 0.0;
41  } else {
42  J[0] = 0.0;
43  J[1] = 0.0;
44  J[2] = 0.0;
45  }
46 
47  return J;
48 }
49 
50 inline Tensor<1, 3>
51 magnetic_field_coil(double x,
52  double y,
53  double z,
54  double K_0,
55  double mu_0,
56  double a,
57  double b)
58 {
59  double cos_theta;
60  double sin_theta;
61 
62  double cos_phi;
63  double sin_phi;
64 
65  Tensor<1, 3> r_hat;
66  Tensor<1, 3> theta_hat;
67 
68  Tensor<1, 3> F1;
69  Tensor<1, 3> F2;
70  Tensor<1, 3> B;
71 
72  double r;
73 
74  r = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
75 
76  cos_theta = z / r;
77  sin_theta = sqrt(pow(x, 2) + pow(y, 2)) / r;
78 
79  cos_phi = x / sqrt(pow(x, 2) + pow(y, 2));
80  sin_phi = y / sqrt(pow(x, 2) + pow(y, 2));
81 
82  r_hat[0] = x / r;
83  r_hat[1] = y / r;
84  r_hat[2] = z / r;
85 
86  theta_hat[0] = cos_theta * cos_phi;
87  theta_hat[1] = cos_theta * sin_phi;
88  theta_hat[2] = -sin_theta;
89 
90  F1 = (2.0 / 3.0) * mu_0 * K_0 * (cos_theta * r_hat - sin_theta * theta_hat);
91  F2 = (2.0 / 3.0) * mu_0 * K_0 *
92  (cos_theta * r_hat + 0.5 * sin_theta * theta_hat) / pow(r, 3);
93 
94  if (r < a) {
95  B = 0.5 * (pow(b, 2) - pow(a, 2)) * F1;
96  } else if (r > b) {
97  B = 0.2 * (pow(b, 5) - pow(a, 5)) * F2;
98  } else {
99  B = 0.5 * (pow(b, 2) - pow(r, 2)) * F1 + 0.2 * (pow(r, 5) - pow(a, 5)) * F2;
100  }
101 
102  return B;
103 }
104 
105 inline Tensor<1, 3>
106 magnetic_field_core(double x,
107  double y,
108  double z,
109  double H_0,
110  double mur,
111  double mu0,
112  double a,
113  double b)
114 {
115  double a3 = std::pow(a, 3);
116  double b3 = std::pow(b, 3);
117 
118  double OMEGA = ((mur - 1.0) / (mur + 2.0)) * (a3 / b3);
119  double gamma_1 =
120  (-3.0 * b3 * H_0 * OMEGA) / ((2.0 * mur + 1.0) - 2.0 * (mur - 1.0) * OMEGA);
121  double beta_1 = ((2.0 * mur + 1.0) * gamma_1) / ((mur - 1.0) * a3);
122  double alpha_1 = (-b3 * H_0 + 2.0 * mur * gamma_1 - mur * b3 * beta_1) / 2.0;
123  double delta_1 = (mur * a3 * beta_1 - 2.0 * mur * gamma_1) / a3;
124 
125  double r = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
126  double r3 = std::pow(r, 3.0);
127  double zz = -3.0 * z * z / std::pow(r, 5.0);
128  double xz = -3.0 * x * z / std::pow(r, 5.0);
129  double yz = -3.0 * y * z / std::pow(r, 5.0);
130 
131  double mu;
132 
133  Tensor<1, 3> grad_psi;
134  Tensor<1, 3> B;
135  Tensor<1, 3> Happl;
136 
137  if (r < a) {
138  grad_psi[0] = 0.0;
139  grad_psi[1] = 0.0;
140  grad_psi[2] = delta_1;
141  mu = mu0;
142  } else if (r > b) {
143  grad_psi[0] = alpha_1 * xz;
144  grad_psi[1] = alpha_1 * yz;
145  grad_psi[2] = -H_0 + alpha_1 / r3 + alpha_1 * zz;
146  mu = mu0;
147  } else {
148  grad_psi[0] = gamma_1 * xz;
149  grad_psi[1] = gamma_1 * yz;
150  grad_psi[2] = beta_1 + gamma_1 / r3 + gamma_1 * zz;
151  mu = mur * mu0;
152  }
153 
154  Happl[0] = 0.0;
155  Happl[1] = 0.0;
156  Happl[2] = H_0;
157 
158  B = -mu * grad_psi - mu0 * Happl;
159 
160  return B;
161 }
162 
169  : public Function<3>
170  , public SettingsSSOLIII
171 {
172 public:
174 
175  virtual void vector_value_list(
176  const std::vector<Point<3>>& r,
177  std::vector<Vector<double>>& values) const override final;
178 };
179 
186  : public Function<3>
187  , public SettingsSSOLIII
188 {
189 public:
191 
192  virtual void vector_value_list(
193  const std::vector<Point<3>>& r,
194  std::vector<Vector<double>>& values) const override final;
195 };
196 
197 #endif
Describes exact solution, , of the Spherical coil with magnetic core (ssol-iii/) numerical experiment...
Describes exact solution, , of the Spherical coil with magnetic core (ssol-iii/) numerical experiment...
Global settings for the Spherical coil with magnetic core (ssol-iii/) numerical experiment.
Definition: settings.hpp:26