Skip to content

Commit a551793

Browse files
Add function to set domain boundary potentials from Python (#4740)
* add function to set domain boundary potentials from Python * switch function arguments to form `potential_[lo/hi]_[x/y/z]` and add to docs
1 parent 642aa54 commit a551793

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Docs/source/usage/workflows/python_extend.rst

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ This object is the Python equivalent to the C++ ``WarpX`` simulation class.
9090
9191
.. py:method:: get_particle_boundary_buffer
9292
93+
.. py:method:: set_potential_on_domain_boundary(potential_[lo/hi]_[x/y/z]: str)
94+
95+
The potential on the domain boundaries can be modified when using the electrostatic solver.
96+
This function updates the strings and function parsers which set the domain
97+
boundary potentials during the Poisson solve.
98+
9399
.. py:method:: set_potential_on_eb(potential: str)
94100
95101
The embedded boundary (EB) conditions can be modified when using the electrostatic solver.

Source/Python/WarpX.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,28 @@ The physical fields in WarpX have the following naming:
170170
"Get the current physical time step size on mesh-refinement level ``lev``."
171171
)
172172

173+
.def("set_potential_on_domain_boundary",
174+
[](WarpX& wx,
175+
std::string potential_lo_x, std::string potential_hi_x,
176+
std::string potential_lo_y, std::string potential_hi_y,
177+
std::string potential_lo_z, std::string potential_hi_z)
178+
{
179+
if (potential_lo_x != "") wx.m_poisson_boundary_handler.potential_xlo_str = potential_lo_x;
180+
if (potential_hi_x != "") wx.m_poisson_boundary_handler.potential_xhi_str = potential_hi_x;
181+
if (potential_lo_y != "") wx.m_poisson_boundary_handler.potential_ylo_str = potential_lo_y;
182+
if (potential_hi_y != "") wx.m_poisson_boundary_handler.potential_yhi_str = potential_hi_y;
183+
if (potential_lo_z != "") wx.m_poisson_boundary_handler.potential_zlo_str = potential_lo_z;
184+
if (potential_hi_z != "") wx.m_poisson_boundary_handler.potential_zhi_str = potential_hi_z;
185+
wx.m_poisson_boundary_handler.buildParsers();
186+
},
187+
py::arg("potential_lo_x") = "",
188+
py::arg("potential_hi_x") = "",
189+
py::arg("potential_lo_y") = "",
190+
py::arg("potential_hi_y") = "",
191+
py::arg("potential_lo_z") = "",
192+
py::arg("potential_hi_z") = "",
193+
"Sets the domain boundary potential string(s) and updates the function parser."
194+
)
173195
.def("set_potential_on_eb",
174196
[](WarpX& wx, std::string potential) {
175197
wx.m_poisson_boundary_handler.setPotentialEB(potential);

0 commit comments

Comments
 (0)