|
|
|||
File indexing completed on 2025-11-02 08:52:45
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/Definitions/Algebra.hpp" 0012 #include "Acts/MagneticField/MagneticFieldContext.hpp" 0013 #include "Acts/MagneticField/MagneticFieldProvider.hpp" 0014 #include "Acts/Utilities/Result.hpp" 0015 0016 #include <cstddef> 0017 0018 namespace Acts { 0019 0020 /// @ingroup MagneticField 0021 // 0022 /// @class SolenoidBField 0023 /// Implements a multi-coil solenoid magnetic field. On every call, the field 0024 /// is evaluated at that exact position. The field has radially symmetry, the 0025 /// field vectors point in +z direction. 0026 /// The config exposes a target field value in the center. This value is used 0027 /// to empirically determine a scale factor which reproduces this field value 0028 /// in the center. 0029 /// 0030 /// $E_1(k^2)$ = complete elliptic integral of the 1st kind 0031 /// $E_2(k^2)$ = complete elliptic integral of the 2nd kind 0032 /// 0033 /// $E_1(k^2)$ and $E_2(k^2)$ are usually indicated as $K(k^2)$ and $E(k^2)$ in 0034 /// literature, 0035 /// respectively 0036 /// ``` 0037 /// _ 0038 /// 2 / pi / 2 2 2 - 1 / 2 0039 /// E (k ) = | ( 1 - k sin {theta} ) dtheta 0040 /// 1 _/ 0 0041 /// 0042 /// _ ____________________ 0043 /// 2 / pi / 2| / 2 2 0044 /// E (k ) = | |/ 1 - k sin {theta} dtheta 0045 /// 2 _/ 0 0046 /// 0047 /// k^2 = is a function of the point (r, z) and of the radius of the coil R 0048 /// 0049 /// 2 4Rr 0050 /// k = --------------- 0051 /// 2 2 0052 /// (R + r) + z 0053 /// Using these, you can evaluate the two components B_r and B_z of the 0054 /// magnetic field: 0055 /// _ _ 0056 /// mu I | / 2 \ | 0057 /// 0 kz | |2 - k | 2 2 | 0058 /// B (r, z) = ----- ------ | |-------|E (k ) - E (k ) | 0059 /// r 4pi ___ | | 2| 2 1 | 0060 /// | / 3 |_ \2 - 2k / _| 0061 /// |/ Rr 0062 /// 0063 /// _ _ 0064 /// mu I | / 2 \ | 0065 /// 0 k | | (R + r)k - 2r | 2 2 | 0066 /// B (r,z) = ----- ---- | | -------------- | E (k ) + E (k ) | 0067 /// z 4pi __ | | 2 | 2 1 | 0068 /// |/Rr |_ \ 2r(1 - k ) / _| 0069 /// ``` 0070 /// 0071 class SolenoidBField final : public MagneticFieldProvider { 0072 public: 0073 struct Cache { 0074 /// @brief Constructor with magnetic field context 0075 explicit Cache(const MagneticFieldContext& /*mctx*/) {} 0076 }; 0077 0078 /// Config struct for the SolenoidBfield. 0079 struct Config { 0080 /// Radius at which the coils are located. 0081 double radius; 0082 /// Extent of the solenoid in z. It goes from 0083 /// -length/2 to +length/2 by convention 0084 double length; 0085 /// The number of coils that make up the solenoid 0086 std::size_t nCoils; 0087 /// The target magnetic field strength at the center. 0088 /// This will be used to scale coefficients 0089 double bMagCenter; 0090 }; 0091 0092 /// @brief the constructor with a shared pointer 0093 /// @note since it is a shared field, we enforce it to be const 0094 /// @tparam bField is the shared BField to be stored 0095 /// @param config Configuration struct containing solenoid parameters 0096 explicit SolenoidBField(Config config); 0097 0098 /// @brief Retrieve magnetic field value in local (r,z) coordinates 0099 /// 0100 /// @param [in] position local 2D position 0101 /// @return Magnetic field vector in local (r,z) coordinates 0102 Vector2 getField(const Vector2& position) const; 0103 0104 /// @copydoc MagneticFieldProvider::makeCache(const MagneticFieldContext&) const 0105 MagneticFieldProvider::Cache makeCache( 0106 const MagneticFieldContext& mctx) const override; 0107 0108 /// @brief Get the B field at a position 0109 /// 0110 /// @param position The position to query at 0111 /// @return Magnetic field vector in global coordinates 0112 Vector3 getField(const Vector3& position) const; 0113 0114 /// @copydoc MagneticFieldProvider::getField(const Vector3&,MagneticFieldProvider::Cache&) const 0115 Result<Vector3> getField(const Vector3& position, 0116 MagneticFieldProvider::Cache& cache) const override; 0117 0118 private: 0119 Config m_cfg; 0120 double m_scale; 0121 double m_dz; 0122 double m_R2; 0123 0124 Vector2 multiCoilField(const Vector2& pos, double scale) const; 0125 0126 Vector2 singleCoilField(const Vector2& pos, double scale) const; 0127 0128 double B_r(const Vector2& pos, double scale) const; 0129 0130 double B_z(const Vector2& pos, double scale) const; 0131 0132 double k2(double r, double z) const; 0133 }; 0134 0135 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|