Skip to content

Commit

Permalink
Merge branch 'KATRIN-Experiment:main' into 2xB/timeoutput
Browse files Browse the repository at this point in the history
  • Loading branch information
2xB authored Jul 8, 2024
2 parents cbae337 + 890b097 commit 12aedce
Show file tree
Hide file tree
Showing 13 changed files with 2,501 additions and 2,396 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:
branches: [ "main" ]

# Keep the following in sync with Documentation/gh-pages/source/compiling.rst !
# Keep the following in sync with Documentation/gh-pages/source/setup_manual.rst !
jobs:
ubuntu_20_04:
strategy:
Expand Down Expand Up @@ -51,20 +51,14 @@ jobs:
source root/bin/thisroot.sh && source install/bin/kasperenv.sh && UnitTestKasper
shell: bash

fedora_37:
fedora_40:
strategy:
matrix:
use_clang: [false] # FIXME add "true" after solving https://github.com/KATRIN-Experiment/Kassiopeia/issues/87
runs-on: ubuntu-latest
container: fedora:37
container: fedora:40
steps:
- uses: actions/checkout@v3
- name: Run workaround for log4cxx bug (no longer needed with Fedora 39)
run: |
dnf update -y
dnf install -y --setopt=install_weak_deps=False dnf-plugins-core
dnf clean all
dnf copr enable thofmann/log4xx-1.x -y
- name: Install dependencies
run: |
dnf install -y \
Expand Down
2 changes: 2 additions & 0 deletions Docker/packages.full
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ vim
zsh
zsh-syntax-highlighting
htop
diffutils
paraview

root
root-notebook
Expand Down
11 changes: 2 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,14 @@ ARG KASSIOPEIA_GIT_COMMIT=""
ARG KASSIOPEIA_CPUS=""

# --- runtime-base ---
# NOTE: For Fedora 39, remove marked lines below
FROM fedora:38 as runtime-base
FROM fedora:40 as runtime-base
ARG KASSIOPEIA_UID
ARG KASSIOPEIA_USER
ARG KASSIOPEIA_GID
ARG KASSIOPEIA_GROUP

LABEL description="Runtime base container"

# TODO REMOVE FOR FEDORA 39
RUN dnf update -y \
&& dnf install -y --setopt=install_weak_deps=False dnf-plugins-core \
&& dnf clean all
RUN dnf copr enable thofmann/log4xx-1.x -y
# END TODO

COPY Docker/packages.runtime packages
RUN dnf update -y \
&& dnf install -y --setopt=install_weak_deps=False $(cat packages) \
Expand Down Expand Up @@ -144,6 +136,7 @@ RUN pip3 install --no-cache-dir jupyterlab \
&& pip3 install --no-cache-dir jupyter-server-proxy \
&& pip3 install --no-cache-dir jupyterhub \
&& pip3 install --no-cache-dir ipympl \
&& pip3 install --no-cache-dir uproot \
&& pip3 install --no-cache-dir iminuit

# Ensure if LDAP is used on a JupyterHub, user names are correctly resolved
Expand Down
2 changes: 1 addition & 1 deletion Documentation/gh-pages/source/setup_manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ On a RedHat/Fedora Linux system, the packages can be installed through the comma
boost-devel fftw-devel gsl-devel hdf5-devel libomp-devel liburing-devel libxml2-devel log4cxx-devel \
ocl-icd-devel openmpi-devel openssl-devel sqlite-devel vtk-devel zlib-devel
Tested on Fedora Linux 37.
Tested on Fedora Linux 40.

Required dependencies
----------------------
Expand Down
3 changes: 1 addition & 2 deletions KEMField/Source/ExternalFields/MagfieldCoils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ foreach( BASENAME ${MAGFIELDCOILS_SOURCE_BASENAMES} )
list( APPEND MAGFIELDCOILS_SOURCEFILES ${MAGFIELDCOILS_SOURCE_PATH}/${BASENAME} )
endforeach( BASENAME )

set_property(SOURCE ${MAGFIELDCOILS_SOURCEFILES} APPEND_STRING PROPERTY COMPILE_OPTIONS -Wno-error) # FIXME

add_library (KEMMagfieldCoils SHARED
${MAGFIELDCOILS_SOURCEFILES} ${MAGFIELDCOILS_HEADERFILES})
target_include_directories(KEMMagfieldCoils
Expand All @@ -50,6 +48,7 @@ target_link_libraries (KEMMagfieldCoils
# KEMCore
# KEMMath
# KEMFieldSolverCore
KEMFieldExceptions
)

kasper_install_headers (${MAGFIELDCOILS_HEADERFILES})
Expand Down
229 changes: 117 additions & 112 deletions KEMField/Source/ExternalFields/MagfieldCoils/include/MagfieldCoils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
#ifndef MagfieldCoils_h
#define MagfieldCoils_h

#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

Expand All @@ -20,168 +20,173 @@ using namespace std;
class MagfieldCoils
{
public:
MagfieldCoils(string inputdirname, string inputobjectname, string inputcoilfilename,
int inputNelliptic, int inputnmax, double inputepstol); // constructor
MagfieldCoils(string inputdirname, string inputobjectname);
~MagfieldCoils(); // deconstructor
bool Magfield(const double *P, double *B);
void MagfieldElliptic(const double *P, double *B);
void SetTrackingStart();
MagfieldCoils(string inputdirname, string inputobjectname, string inputcoilfilename, int inputNelliptic,
int inputnmax, double inputepstol); // constructor
MagfieldCoils(string inputdirname, string inputobjectname);
~MagfieldCoils(); // deconstructor
bool Magfield(const double* P, double* B);
void MagfieldElliptic(const double* P, double* B);
void SetTrackingStart();

private:
// MEMBER FUNCTIONS:
// General:
void CoilRead();
void CoilGroupWrite();
void CoilGroupRead();
void MagsourceRead();
void DynamicMemoryAllocations();
// Elliptic:
void Magfield2EllipticCoil(int i, double z, double r, double& Bz,double& Br);
void MagfieldEllipticCoil(int i, const double *P, double *B);
// Source Remote:
double Funrorem(int i, double z0);
void Magsource2RemoteCoil(int i, double z0, double rorem);
void MagsourceRemoteCoils();
void MagsourceRemoteGroups();
void RemoteSourcepointGroup(int g);
// Source Magcharge:
// MEMBER FUNCTIONS:
// General:
void CoilRead();
void CoilGroupWrite();
void CoilGroupRead();
void MagsourceRead();
void DynamicMemoryAllocations();
// Elliptic:
void Magfield2EllipticCoil(int i, double z, double r, double& Bz, double& Br);
void MagfieldEllipticCoil(int i, const double* P, double* B);
// Source Remote:
double Funrorem(int i, double z0);
void Magsource2RemoteCoil(int i, double z0, double rorem);
void MagsourceRemoteCoils();
void MagsourceRemoteGroups();
void RemoteSourcepointGroup(int g);
// Source Magcharge:
void MagsourceMagchargeCoils();
// Source Central:
double Funrocen(int i, double z0);
double FunrocenG(int g, double z0);
void Magsource2CentralCoil(int i, double z0, double rocen);
void MagsourceCentralCoils();
void CentralSourcepointsCoil(int i);
void MagsourceCentralGroups();
void CentralSourcepointsGroup(int g);
// Magfield Remote:
bool Magfield2Remote(bool coil, int ig, double z, double r, double& Bz,double& Br,double& rc);
// Magfield Magcharge:
// Source Central:
double Funrocen(int i, double z0);
double FunrocenG(int g, double z0);
void Magsource2CentralCoil(int i, double z0, double rocen);
void MagsourceCentralCoils();
void CentralSourcepointsCoil(int i);
void MagsourceCentralGroups();
void CentralSourcepointsGroup(int g);
// Magfield Remote:
bool Magfield2Remote(bool coil, int ig, double z, double r, double& Bz, double& Br, double& rc);
// Magfield Magcharge:
bool Magfield2Magcharge(int i, double z, double r, double& Bz, double& Br, double& rc);
bool Hfield(int i, double z, double r, double& Hz, double& Hr, double& rc);
// Magfield Central:
bool Magfield2Central(bool coil, int ig, int j, double z, double r, double& Bz,double& Br,double& rc);
// Magfield Coil, Group:
bool MagfieldCoil(int i, const double *P, double *B);
bool MagfieldGroup(int g, const double *P, double *B);
// Magfield Central:
bool Magfield2Central(bool coil, int ig, int j, double z, double r, double& Bz, double& Br, double& rc);
// Magfield Coil, Group:
bool MagfieldCoil(int i, const double* P, double* B);
bool MagfieldGroup(int g, const double* P, double* B);
bool SourcePointSearching(bool coil, int ig, double z, double r, int type, int& jbest, double& rcbest);
// Integration:
void GaussLegendreIntegration(int& N, double a, double b, double* x, double* w);
// Carlson elliptic:
double RF_Carlson(double x,double y,double z);
double RD_Carlson(double x,double y,double z);
double RJ_Carlson(double x,double y,double z,double p);
double RC_Carlson(double x,double y);
// Simple:
double pow2(double x);
double FMIN(double a, double b);
double FMAX(double a, double b);
double FMIN3(double a, double b, double c);
double FMAX3(double a, double b, double c);
double Mag(double* vec);
double Mag(double x, double y, double z);
// VARIABLES:
int Ncoil; // number of coils; coil indexing: i=0, ..., Ncoil-1
double** coil; // coil parameters: coil[i][j], i=0, ..., Ncoil-1; j=0,...,13.
string dirname; // name of directory where the coil and source coefficient data files are stored
string coilfilename; // name of coil input file
string objectname; // this string identifies the Magfield object (used as starting part of the source files)
int Nelliptic; // radial numerical integration parameter for magnetic field calc. with elliptic integrals
int nmax; // number of source coefficients for fixed z: nmax+1
double epstol; // small tolerance parameter needed for the symmetry group definitions (distance: in meter)
int Ng; // number of coil symmetry groups; group indexing: g=0, ..., Ng-1
int* G; // coil with global index i is in symmetry group g=G[i], i=0,...,Ncoil-1
int* Nc; // number of coils in symmetry group g: Nc[g]; local coil indexing in group g: c=0,..., Nc[g]-1
int** Cin; // global coil indices i in symmetry group g: i=Cin[g][c],...,c=0 to Nc[g]-1 (g=0,...,Ng-1)
double** Line; // symmetry group axis line of symmetry group g (g=0,...,Ng-1):
// line point: Line[g][0], Line[g][1], Line[g][2]; line direction unit vector: Line[g][3], Line[g][4], Line[g][5];
double** Z; // local z coordinate of coil center in symmetry group g: Z[g][c], c=0,..., Nc[g]-1; Z[g][0]=0
// (g: group index, c: local coil index)
double *C0, *C1, *c1, *c2, *c3, *c4, *c5, *c6, *c7, *c8, *c9, *c10, *c11, *c12;

double* Pp, *P; // Legendre polynomial P and first derivative Pp
double* Bzplus, *Brplus; // used in Bz and Br mag. field calc.
// Remote source constant variables:
double* Brem1; // 1-dim. remote source constants Brem1[n], n=2,...,nmax.
double* rorem; // remote convergence radius for coil i: rorem[i]
double** Brem; // remote source constant for coil i: Brem[i][n] (coil index i, source constant index n)
double* z0remG; // remote source point for group G: z0remG[g]
double* roremG; // remote convergence radius for group G: roremG[g]
double** BremG; // remote source constant for symmetry group g: BremG[g][n] (group index g, source constant index n)
// Magnetic charge source constant variables:
double** Vrem; // magnetic charge remote source constant for coil i: Vrem[i][n] (coil index i, source const. index n)
// Central source constant variables:
double* Bcen1; // 1-dim. central source constants Bcen1[n], n=0,...,nmax.
int* Nsp; // number of central source points for coil i: Nsp[i] (i=0,...,Ncoil-1)
double** z0cen; // central source point local z value for coil i: z0cen[i][j] (coil index i, source point index j)
double** rocen; // central convergence radius for coil i: rocen[i][j] (coil index i, source point index j)
double*** Bcen; // central source constant for coil i: Bcen[i][j][n] (coil index i, source point index j, source constant index n)
int* NspG; // number of central source points for group g: Nsp[g] (g=0,...,Ng-1)
double** z0cenG; // central source point local z value: z0cenG[g][j] (group index g, source point index j)
double** rocenG; // central convergence radius: rocenG[g][j] (group index g, source point index j)
double*** BcenG; // central source constant: BcenG[g][j][n] (group index g, source point index j, source const. index n)
int *jlast, *jlastG; // last central source point index for coil and group calculation
double rclimit;
// Integration:
void GaussLegendreIntegration(int& N, double a, double b, double* x, double* w);
// Carlson elliptic:
double RF_Carlson(double x, double y, double z);
double RD_Carlson(double x, double y, double z);
double RJ_Carlson(double x, double y, double z, double p);
double RC_Carlson(double x, double y);
// Simple:
double pow2(double x);
double FMIN(double a, double b);
double FMAX(double a, double b);
double FMIN3(double a, double b, double c);
double FMAX3(double a, double b, double c);
double Mag(double* vec);
double Mag(double x, double y, double z);
// VARIABLES:
int fNcoil; // number of coils; coil indexing: i=0, ..., Ncoil-1
double** fcoil; // coil parameters: coil[i][j], i=0, ..., Ncoil-1; j=0,...,13.
string fdirname; // name of directory where the coil and source coefficient data files are stored
string fcoilfilename; // name of coil input file
string fobjectname; // this string identifies the Magfield object (used as starting part of the source files)
int fNelliptic; // radial numerical integration parameter for magnetic field calc. with elliptic integrals
int fnmax; // number of source coefficients for fixed z: nmax+1
double fepstol; // small tolerance parameter needed for the symmetry group definitions (distance: in meter)
int fNg; // number of coil symmetry groups; group indexing: g=0, ..., Ng-1
int* fG; // coil with global index i is in symmetry group g=G[i], i=0,...,Ncoil-1
int* fNc; // number of coils in symmetry group g: Nc[g]; local coil indexing in group g: c=0,..., Nc[g]-1
int** fCin; // global coil indices i in symmetry group g: i=Cin[g][c],...,c=0 to Nc[g]-1 (g=0,...,Ng-1)
double** fLine; // symmetry group axis line of symmetry group g (g=0,...,Ng-1):
// line point: Line[g][0], Line[g][1], Line[g][2]; line direction unit vector: Line[g][3], Line[g][4], Line[g][5];
double** fZ; // local z coordinate of coil center in symmetry group g: Z[g][c], c=0,..., Nc[g]-1; Z[g][0]=0
// (g: group index, c: local coil index)
double *fC0, *fC1, *fc1, *fc2, *fc3, *fc4, *fc5, *fc6, *fc7, *fc8, *fc9, *fc10, *fc11, *fc12;

double *fPp, *fP; // Legendre polynomial P and first derivative Pp
double *fBzplus, *fBrplus; // used in Bz and Br mag. field calc.
// Remote source constant variables:
double* fBrem1; // 1-dim. remote source constants Brem1[n], n=2,...,nmax.
double* frorem; // remote convergence radius for coil i: rorem[i]
double** fBrem; // remote source constant for coil i: Brem[i][n] (coil index i, source constant index n)
double* fz0remG; // remote source point for group G: z0remG[g]
double* froremG; // remote convergence radius for group G: roremG[g]
double**
fBremG; // remote source constant for symmetry group g: BremG[g][n] (group index g, source constant index n)
// Magnetic charge source constant variables:
double**
fVrem; // magnetic charge remote source constant for coil i: Vrem[i][n] (coil index i, source const. index n)
// Central source constant variables:
double* fBcen1; // 1-dim. central source constants Bcen1[n], n=0,...,nmax.
int* fNsp; // number of central source points for coil i: Nsp[i] (i=0,...,Ncoil-1)
double** fz0cen; // central source point local z value for coil i: z0cen[i][j] (coil index i, source point index j)
double** frocen; // central convergence radius for coil i: rocen[i][j] (coil index i, source point index j)
double***
fBcen; // central source constant for coil i: Bcen[i][j][n] (coil index i, source point index j, source constant index n)
int* fNspG; // number of central source points for group g: Nsp[g] (g=0,...,Ng-1)
double** fz0cenG; // central source point local z value: z0cenG[g][j] (group index g, source point index j)
double** frocenG; // central convergence radius: rocenG[g][j] (group index g, source point index j)
double***
fBcenG; // central source constant: BcenG[g][j][n] (group index g, source point index j, source const. index n)
int *fjlast, *fjlastG; // last central source point index for coil and group calculation
double frclimit;
};


////////////////////////////////////////////////////////

inline double MagfieldCoils::pow2(double x)
{
return x*x;
return x * x;
}

////////////////////////////////////////////////////////

inline double MagfieldCoils::FMIN(double a, double b)
{
return ((a)<=(b)?(a):(b));
return ((a) <= (b) ? (a) : (b));
}

////////////////////////////////////////////////////////

inline double MagfieldCoils::FMAX(double a, double b)
{
return ((a)>(b)?(a):(b));
return ((a) > (b) ? (a) : (b));
}

////////////////////////////////////////////////////////

inline double MagfieldCoils::FMIN3(double a, double b, double c)
{
return (FMIN(a,b)<=(c)?(FMIN(a,b)):(c));
return (FMIN(a, b) <= (c) ? (FMIN(a, b)) : (c));
}

////////////////////////////////////////////////////////

inline double MagfieldCoils::FMAX3(double a, double b, double c)
{
return (FMAX(a,b)>(c)?(FMAX(a,b)):(c));
return (FMAX(a, b) > (c) ? (FMAX(a, b)) : (c));
}

////////////////////////////////////////////////////////

inline double MagfieldCoils::Mag(double* vec)
{
return sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]);
return sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
}

////////////////////////////////////////////////////////

inline double MagfieldCoils::Mag(double x, double y, double z)
{
return sqrt(x*x+y*y+z*z);
return sqrt(x * x + y * y + z * z);
}

////////////////////////////////////////////////////////

inline void MagfieldCoils::SetTrackingStart()
{
for(int i=0; i<Ncoil; i++)
jlast[i]=-1;
for(int g=0; g<Ng; g++)
jlastG[g]=-1;
for (int i = 0; i < fNcoil; i++)
fjlast[i] = -1;
for (int g = 0; g < fNg; g++)
fjlastG[g] = -1;
}


Expand Down
Loading

0 comments on commit 12aedce

Please sign in to comment.