Skip to content

Commit

Permalink
Add LinearMap to 'Named' elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
cemitch99 committed Nov 2, 2024
1 parent 06718d8 commit 2e57e91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
10 changes: 7 additions & 3 deletions src/particles/elements/LinearMap.H
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "mixin/beamoptic.H"
#include "mixin/lineartransport.H"
#include "mixin/thin.H"
#include "mixin/named.H"
#include "mixin/nofinalize.H"

#include <AMReX_Extension.H>
Expand All @@ -26,7 +27,8 @@
namespace impactx
{
struct LinearMap
: public elements::BeamOptic<LinearMap>,
: public elements::Named,
public elements::BeamOptic<LinearMap>,
public elements::Thin,
public elements::Alignment,
public elements::LinearTransport,
Expand All @@ -49,9 +51,11 @@ namespace impactx
LinearTransport::Map6x6 const & R,
amrex::ParticleReal dx = 0,
amrex::ParticleReal dy = 0,
amrex::ParticleReal rotation_degree = 0
amrex::ParticleReal rotation_degree = 0,
std::optional<std::string> name = std::nullopt
)
: Alignment(dx, dy, rotation_degree)
: Named(name),
Alignment(dx, dy, rotation_degree)
{
for (int i=1; i<=6; ++i) {
for (int j = 1; j <= 6; ++j) {
Expand Down
25 changes: 12 additions & 13 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <particles/Push.H>
#include <particles/elements/All.H>
#include <particles/elements/mixin/lineartransport.H>
#include <AMReX.H>

#include <optional>
Expand Down Expand Up @@ -1480,7 +1481,7 @@ void init_elements(py::module& m)
;
register_beamoptics_push(py_TaperedPL);

py::class_<LinearMap, elements::Named, elements::Thin, elements::Alignment> py_LinearMap(me, "LinearMap");
py::class_<LinearMap, elements::Named, elements::Thin, elements::Alignment, elements::LinearTransport> py_LinearMap(me, "LinearMap");
py_LinearMap
.def("__repr__",
[](LinearMap const & linearmap) {
Expand All @@ -1490,17 +1491,14 @@ void init_elements(py::module& m)
);
}
)
.def(py::init([](
elements::LinearTransport::Map6x6 R,
amrex::ParticleReal dx,
amrex::ParticleReal dy,
amrex::ParticleReal rotation_degree,
std::optional<std::string> name
)
{
}),
.def(py::init<
elements::LinearTransport::Map6x6,
amrex::ParticleReal,
amrex::ParticleReal,
amrex::ParticleReal,
std::optional<std::string>
>(),
py::arg("R"),
py::arg("unit") = "dimensionless",
py::arg("dx") = 0,
py::arg("dy") = 0,
py::arg("rotation") = 0,
Expand All @@ -1509,10 +1507,11 @@ void init_elements(py::module& m)
)
.def_property("R",
[](LinearMap & linearmap) { return linearmap.m_transport_map; },
[](LinearMap & linearmap, LinearTransport::Map6x6 R) { linearmap.m_transport_map = linearmap; },
[](LinearMap & linearmap, elements::LinearTransport::Map6x6 R) { linearmap.m_transport_map = R; },
"linear map as a 6x6 transport matrix"
)

;
register_beamoptics_push(py_LinearMap);

// freestanding push function
m.def("push", &Push,
Expand Down

0 comments on commit 2e57e91

Please sign in to comment.