Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: None -> Empty Element/Dist #593

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/usage/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ This module provides particle beam distributions that can be used to initialize
A K-V distribution transversely + a uniform distribution
in t + a Gaussian distribution in pt.

.. py:class:: impactx.distribution.None
.. py:class:: impactx.distribution.Empty

This distribution sets all values to zero.

Expand Down Expand Up @@ -564,7 +564,7 @@ This module provides elements for the accelerator lattice.
:param dy: vertical translation error in m
:param rotation: rotation error in the transverse plane [degrees]

.. py::class:: impactx.elements.None
.. py::class:: impactx.elements.Empty

This element does nothing.

Expand Down
1 change: 0 additions & 1 deletion examples/aperture/run_aperture.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# -*- coding: utf-8 -*-

import amrex.space3d as amr

from impactx import ImpactX, distribution, elements

# work-around for https://github.com/ECP-WarpX/impactx/issues/499
Expand Down
1 change: 0 additions & 1 deletion examples/fodo_tune/run_fodo_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# -*- coding: utf-8 -*-

import amrex.space3d as amr

from impactx import ImpactX, distribution, elements

sim = ImpactX()
Expand Down
1 change: 0 additions & 1 deletion examples/initialize_from_array/run_from_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import amrex.space3d as amr
import numpy as np
import transformation_utilities as pycoord

from impactx import Config, ImpactX, elements

################
Expand Down
5 changes: 2 additions & 3 deletions examples/optimize_triplet/run_triplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
# -*- coding: utf-8 -*-

import amrex.space3d as amr
import numpy as np
from scipy.optimize import minimize

import impactx
import numpy as np
from impactx import ImpactX, distribution, elements
from scipy.optimize import minimize

# Call MPI_Init and MPI_Finalize only once:
if impactx.Config.have_mpi:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import numpy as np
import scipy.optimize as opt
from surrogate_model_definitions import surrogate_model

from impactx import (
Config,
CoordSystem,
Expand All @@ -31,6 +29,7 @@
distribution,
elements,
)
from surrogate_model_definitions import surrogate_model

try:
import torch
Expand Down
4 changes: 2 additions & 2 deletions src/particles/distribution/All.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Kurth4D.H"
#include "Kurth6D.H"
#include "KVdist.H"
#include "None.H"
#include "Empty.H"
#include "Semigaussian.H"
#include "Thermal.H"
#include "Triangle.H"
Expand All @@ -26,7 +26,7 @@
namespace impactx::distribution
{
using KnownDistributions = std::variant<
None, /* must be first, so KnownDistributions creates a default constructor */
Empty, /* must be first, so KnownDistributions creates a default constructor */
Gaussian,
Kurth4D,
Kurth6D,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* Authors: Chad Mitchell, Axel Huebl
* License: BSD-3-Clause-LBNL
*/
#ifndef IMPACTX_DISTRIBUTION_NONE
#define IMPACTX_DISTRIBUTION_NONE
#ifndef IMPACTX_DISTRIBUTION_EMPTY_H
#define IMPACTX_DISTRIBUTION_EMPTY_H

#include "particles/ReferenceParticle.H"

Expand All @@ -18,11 +18,11 @@

namespace impactx::distribution
{
struct None
struct Empty
{
/** This distribution sets all values to zero.
*/
None()
Empty()
{
}

Expand Down Expand Up @@ -81,4 +81,4 @@ namespace impactx::distribution

} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_NONE
#endif // IMPACTX_DISTRIBUTION_EMPTY_H
4 changes: 2 additions & 2 deletions src/particles/elements/All.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "ExactSbend.H"
#include "Kicker.H"
#include "Multipole.H"
#include "None.H"
#include "Empty.H"
#include "NonlinearLens.H"
#include "Programmable.H"
#include "Quad.H"
Expand All @@ -44,7 +44,7 @@
namespace impactx
{
using KnownElements = std::variant<
None, /* must be first, so KnownElements creates a default constructor */
Empty, /* must be first, so KnownElements creates a default constructor */
Aperture,
Buncher,
CFbend,
Expand Down
10 changes: 5 additions & 5 deletions src/particles/elements/None.H → src/particles/elements/Empty.H
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* Authors: Axel Huebl
* License: BSD-3-Clause-LBNL
*/
#ifndef IMPACTX_NONE_H
#define IMPACTX_NONE_H
#ifndef IMPACTX_ELEMENT_EMPTY_H
#define IMPACTX_ELEMENT_EMPTY_H

#include "particles/ImpactXParticleContainer.H"
#include "mixin/thin.H"
Expand All @@ -20,7 +20,7 @@

namespace impactx
{
struct None
struct Empty
: public elements::Thin,
public elements::NoFinalize
{
Expand All @@ -29,7 +29,7 @@ namespace impactx

/** This element does nothing.
*/
None ()
Empty ()
{
}

Expand Down Expand Up @@ -81,4 +81,4 @@ namespace impactx

} // namespace impactx

#endif // IMPACTX_NONE_H
#endif // IMPACTX_ELEMENT_EMPTY_H
2 changes: 1 addition & 1 deletion src/python/distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void init_distribution(py::module& m)
"in t + a Gaussian distribution in pt"
);

py::class_<distribution::None>(md, "None")
py::class_<distribution::Empty>(md, "Empty")
.def(py::init<>(),
"Sets all values to zero."
);
Expand Down
6 changes: 3 additions & 3 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,11 @@ void init_elements(py::module& m)
;
register_beamoptics_push(py_Multipole);

py::class_<None, elements::Thin> py_None(me, "None");
py::class_<Empty, elements::Thin> py_None(me, "Empty");
py_None
.def("__repr__",
[](None const & /* none */) {
return std::string("<impactx.elements.None>");
[](Empty const & /* none */) {
return std::string("<impactx.elements.Empty>");
}
)
.def(py::init<>(),
Expand Down
1 change: 0 additions & 1 deletion src/python/impactx/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ from __future__ import annotations
import os as os

from amrex import space3d as amr

from impactx.impactx_pybind import (
Config,
CoordSystem,
Expand Down
3 changes: 1 addition & 2 deletions tests/python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import os

import amrex.space3d as amr
import pytest

import impactx
import pytest

if impactx.Config.have_mpi:
from mpi4py import MPI # noqa
Expand Down
3 changes: 1 addition & 2 deletions tests/python/test_charge_deposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
import math

import amrex.space3d as amr
import impactx
import matplotlib.pyplot as plt
import numpy as np
from conftest import basepath

import impactx


def test_charge_deposition(save_png=True):
"""
Expand Down
1 change: 0 additions & 1 deletion tests/python/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import matplotlib.pyplot as plt
import pytest

from impactx import ImpactX, amr, distribution, elements


Expand Down
1 change: 0 additions & 1 deletion tests/python/test_impactx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import numpy as np
import pytest
from conftest import basepath

from impactx import ImpactX, distribution, elements

# FIXME in AMReX via https://github.com/AMReX-Codes/amrex/pull/3727
Expand Down
1 change: 0 additions & 1 deletion tests/python/test_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import numpy as np
import pytest

from impactx import CoordSystem, ImpactX, coordinate_transformation, distribution


Expand Down
3 changes: 1 addition & 2 deletions tests/python/test_xopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import importlib

import amrex.space3d as amr
import impactx
import numpy as np
import pytest

import impactx
from impactx import ImpactX, distribution, elements

# configure the test
Expand Down
Loading