Skip to content

Commit cc6f6d7

Browse files
Gradient Descent (#181)
* Added ArbitraryDistributionVolumeEmitter * Updated particle weight calculation * renamed thermionic_emission test directory to emission * arbitrary seed from uniform distribution * Bug fixes and changes to test * add test for arbitrary seeding * Changed position sampling, added test * Removed unused imports and code * revert traceback printout * Added comments for binning particle positions * increased rtol for test * Allow input of any 2d array, add interpolation of 2d array onto current simulation grid * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated changelog * update version * created steady_state_descent.py file * Added coarsening algorithm * Added ability to read numpy data and coarsen grid * Added regression function calculation * Solve system of equations rather than curve fit * Use skimage block_reduce * Hard coded inverse exponential solve * take mean if exponential equation can't be solved * Added special cases to use linear regression * Update docstring * Added command line arguments * Modified linear regression logic and added main function * Added entry point * Change output file name * Change output file name * Fixed interpolate grid * updated arbitrary distribution emitter test * Fix interpolation logic * Changed to take in exact prediction timestep rather than a multiple * Added ability to specify save directory * Updated docstrings, removed unneeded files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added gradient descent test, refactored code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Changed test parameters * Increase rtol of arbitrary seed test by 0.01 * Update mewarpx/mewarpx/utils_store/plasma_density_oracle.py Co-authored-by: Roelof Groenewald <[email protected]> * Update changelog * Update version * Add controller for plasma density oracle * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * WIP oracle control * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Allow oracle control bins to be overridden * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added command line arguments * Fixed bugs, added info logging * added ability to modify run_script * removed unnecessary code * Cleaned up code * Refactored code to be clearer * Update docstrings * Added test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added documentation about oracle_control * Updated changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixed TOTAL_TIME calculation * update wheel in docker build * change numpy to oldest-supported-numpy for docker * Updated formatting and documentation Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 0d2d104 commit cc6f6d7

18 files changed

+688
-18
lines changed

mewarpx/changelog.csv

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
Version, Physics version, Date, List of changes
2-
8.2.1, 2, In progress, "
2+
8.3.0, 2, In progress, "
3+
4+
**Features**:
5+
6+
- Added
7+
:class:`mewarpx.utils_store.plasma_density_oracle.PlasmaDensityOracle` to
8+
predict particle densities at a given time point based on 3 input data points.
9+
- Added :class:`mewarpx.utils_store.oracle_control.OracleControl`
10+
as a wrapper to automate calling
11+
:class:`mewarpx.utils_store.plasma_density_oracle.PlasmaDensityOracle`
12+
by automatically determining the best parameters for it.
13+
14+
"
15+
8.2.1, 2, 5/31/2022, "
316

417
**Other changes**:
518

@@ -8,12 +21,14 @@ Version, Physics version, Date, List of changes
821
"
922
8.2.0, 2, 5/11/2022, "
1023

24+
1125
**Features**:
1226

1327
- Added :class:`mewarpx.utils_store.json_util.MEWarpXEncoder` to encode a
1428
runinfo object into a JSON string.
1529
- Changed runinfo to be saved as JSON file instead of dpkl file.
1630

31+
"
1732
8.1.1, 2, 5/9/2022, "
1833

1934
**API Changes**:

mewarpx/medocker/docker_shared/python_packages.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ INSTALL_CMD="python3 -m pip install --no-build-isolation "
1616
# internal warnings
1717
# https://github.com/Nike-Inc/gimme-aws-creds/issues/158
1818
python3 -m pip install --upgrade pip
19+
python3 -m pip install --upgrade wheel
1920
python3 -m pip install --upgrade setuptools keyring keyrings.alt
2021

2122
# Build dependency of cmake
@@ -28,7 +29,7 @@ ${INSTALL_CMD} llvmlite
2829

2930
# The builds of scipy and h5py on aarch64 depends on having these already installed
3031
${INSTALL_CMD} cython
31-
${INSTALL_CMD} numpy
32+
${INSTALL_CMD} oldest-supported-numpy
3233
${INSTALL_CMD} pkgconfig
3334

3435
${INSTALL_CMD} numba

mewarpx/mewarpx/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# One and only one place to store the version info
22
# https://stackoverflow.com/questions/458550/standard-way-to-embed-version-into-python-package
3-
__version_info__ = (8, 2, 1)
3+
__version_info__ = (8, 3, 0)
44
__version__ = '.'.join([str(x) for x in __version_info__])
55

66
# One and only one place to store the Physics version

mewarpx/mewarpx/emission.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,8 +2067,7 @@ def _get_x_coords(self, npart):
20672067
class ArbitraryDistributionVolumeEmitter(VolumeEmitter):
20682068

20692069
"""Varies density based on given particle density array. NPPC for each
2070-
species must be an integer greater than or equal to 1. Can only be used
2071-
with FixedNumberInjector."""
2070+
species must be an integer greater than or equal to 1."""
20722071

20732072
geoms = ["XZ"]
20742073

@@ -2100,15 +2099,21 @@ def _interpolate_grid(input_grid):
21002099
output_grid (np.ndarray): 2d array of current simulation dimensions
21012100
interpolated values from input_grid
21022101
"""
2103-
21042102
input_shape = input_grid.shape
2105-
input_x = np.linspace(0.5, input_shape[0] - 0.5, input_shape[0])
2106-
input_z = np.linspace(0.5, input_shape[1] - 0.5, input_shape[1])
2103+
# pad edges with current edge values by 1 to avoid NaN when interpolating
2104+
input_x = np.linspace(-0.5, input_shape[0] + 0.5, input_shape[0] + 2)
2105+
input_z = np.linspace(-0.5, input_shape[1] + 0.5, input_shape[1] + 2)
2106+
input_grid = np.pad(input_grid, (1,), "linear_ramp")
2107+
21072108
input_zz, input_xx = np.meshgrid(input_z, input_x)
2109+
2110+
input_xx = input_xx * mwxrun.nx/input_shape[0]
2111+
input_zz = input_zz * mwxrun.nz/input_shape[1]
21082112
input_coord = np.column_stack([input_xx.flatten(), input_zz.flatten()])
21092113

2110-
output_xx = input_xx * mwxrun.nx/input_shape[0]
2111-
output_zz = input_zz * mwxrun.nz/input_shape[1]
2114+
output_x = np.linspace(0.5, mwxrun.nx - 0.5, mwxrun.nx)
2115+
output_z = np.linspace(0.5, mwxrun.nz - 0.5, mwxrun.nz)
2116+
output_zz, output_xx = np.meshgrid(output_z, output_x)
21122117

21132118
output_grid = scipy.interpolate.griddata(
21142119
input_coord, input_grid.flatten(), (output_xx, output_zz)

0 commit comments

Comments
 (0)