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

Autocompletion of configure.py #357

Merged
merged 38 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
86b6acd
Add autocomplete related
ChunYen-Chen Sep 29, 2024
d640bfb
Let `-lh` be in alphabetical order
ChunYen-Chen Sep 29, 2024
a030aae
Update autocomplete wiki
ChunYen-Chen Sep 29, 2024
3b0c6d4
Add the verbose mode argument
ChunYen-Chen Nov 6, 2024
1afbd63
Merge branch 'autocomplete' of https://github.com/ChunYen-Chen/gamer-…
ChunYen-Chen Nov 6, 2024
8d65cc5
Merge branch 'hyschive:main' into autocomplete
ChunYen-Chen Nov 10, 2024
841bf3f
Merge remote-tracking branch 'gamer_ori/main' into autocomplete
ChunYen-Chen Nov 13, 2024
1cb430e
Merge branch 'master' into autocomplete
ChunYen-Chen Dec 11, 2024
f6ebfd9
Generalize prefix and suffix of simulation option
ChunYen-Chen Dec 11, 2024
c87ef93
Update wiki
ChunYen-Chen Dec 11, 2024
05692f1
Merge remote-tracking branch 'source/main' into autocomplete
ChunYen-Chen Dec 21, 2024
bc69ce0
Support option with `=` autocomplete
ChunYen-Chen Dec 26, 2024
958c189
Support `python configure.py` autocomplete
ChunYen-Chen Dec 28, 2024
fcfb1bf
Style
ChunYen-Chen Jan 15, 2025
fa8de22
Bugfix
ChunYen-Chen Jan 17, 2025
8c77e49
Bugfix
ChunYen-Chen Jan 17, 2025
78d60ff
Fix fallback issue: add trailing space back
technic960183 Jan 17, 2025
8a0d059
Merge pull request #8 from technic960183/357-fix-space
ChunYen-Chen Jan 19, 2025
ee2b899
Move validation to the top of the function
ChunYen-Chen Jan 21, 2025
3685e4d
Check the filename
ChunYen-Chen Jan 21, 2025
2b02e3c
Validate the executed file
ChunYen-Chen Jan 21, 2025
9d9b7df
Avoid long string
ChunYen-Chen Jan 21, 2025
3ee7433
Update wiki
ChunYen-Chen Jan 21, 2025
9f880de
Update wiki
ChunYen-Chen Jan 21, 2025
f8510be
Merge branch 'master' into autocomplete
ChunYen-Chen Jan 22, 2025
c667c4d
Fix wrong merge
ChunYen-Chen Jan 22, 2025
cb46325
Merge branch 'master' into autocomplete
ChunYen-Chen Jan 22, 2025
93a916a
Fix filename check
ChunYen-Chen Jan 23, 2025
aea74a7
chore(docs): Sync wiki to doc/wiki [skip-cd]
ChunYen-Chen Jan 23, 2025
eee01be
Apply suggestions from code review
ChunYen-Chen Feb 4, 2025
97c7c00
Remove prefix and suffix
ChunYen-Chen Feb 4, 2025
530e4e2
Update wiki
ChunYen-Chen Feb 4, 2025
728fc27
Update generate_make.sh
ChunYen-Chen Feb 4, 2025
2fd6853
Move the script
ChunYen-Chen Feb 4, 2025
3b3d51a
Update wiki
ChunYen-Chen Feb 4, 2025
96fe219
Update wiki
ChunYen-Chen Feb 4, 2025
b324df0
Minor
ChunYen-Chen Feb 4, 2025
deb46fa
Merge branch 'hyschive:main' into autocomplete
ChunYen-Chen Feb 4, 2025
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
18 changes: 9 additions & 9 deletions doc/wiki/ELBDM-related/ELBDM-Hybrid-Scheme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mpirun -map-by ppr:2:socket:pe=8 --report-bindings ./gamer 1>>log 2>&1
![Data_000069_PS](https://github.com/gamer-project/gamer/assets/6187378/260649c1-69e7-4a44-8dc9-06ccf6fe798d)
</details>

The wave scheme (`GRAMFE_MATMUL`) is used for the dark grey and black grids.
The wave scheme (`MATMUL`) is used for the dark grey and black grids.
The relative mass conservation error at $z=0$ with spectral interpolation on is $6.72e-04$.


Expand All @@ -90,15 +90,15 @@ The hybrid scheme is particularly suited for cosmological simulations where a si

The configure.py script is the starting point for setting up a simulation. For the hybrid scheme, ensure the following flags are set:

- `--elbdm_scheme = ELBDM_HYBRID`: Determines the scheme type for ELBDM simulations. There are two options:
- `ELBDM_WAVE`: Wave-only scheme.
- `ELBDM_HYBRID`: Fluid-wave hybrid scheme.
- `--elbdm_scheme = HYBRID`: Determines the scheme type for ELBDM simulations. There are two options:
- `WAVE`: Wave-only scheme.
- `HYBRID`: Fluid-wave hybrid scheme.
- `--hybrid_scheme`: This option is specific to the hybrid scheme, defining the fluid dynamics treatment:
- `HYBRID_UPWIND`: First-order upwind scheme. It is diffusive but stable.
- `HYBRID_FROMM`: Second-order Fromm scheme. It has no limiter but can be unstable.
- `HYBRID_MUSCL`: Second-order MUSCL scheme. It includes a limiter, balancing accuracy and stability.
- `UPWIND`: First-order upwind scheme. It is diffusive but stable.
- `FROMM`: Second-order Fromm scheme. It has no limiter but can be unstable.
- `MUSCL`: Second-order MUSCL scheme. It includes a limiter, balancing accuracy and stability.

For zoom-in and fluid-only simulations, use `--hybrid_scheme HYBRID_MUSCL` since unrefined regions may become unstable otherwise. For fully refined simulations use `--hybrid_scheme HYBRID_FROMM` since it is slightly faster and more accurate than `HYBRID_MUSCL`. In case you encounter instabilities, test the more diffusive, first-order scheme `--hybrid_scheme HYBRID_UPWIND`.
For zoom-in and fluid-only simulations, use `--hybrid_scheme MUSCL` since unrefined regions may become unstable otherwise. For fully refined simulations use `--hybrid_scheme FROMM` since it is slightly faster and more accurate than `MUSCL`. In case you encounter instabilities, test the more diffusive, first-order scheme `--hybrid_scheme UPWIND`.

## Configuring the `Input__Parameter` file

Expand Down Expand Up @@ -225,7 +225,7 @@ $$S(x, t) = \arctan\left(\frac{\Im(\psi(x, t))}{\Re(\psi(x, t)}\right).$$
We must therefore determine the correct phase by requiring continuity at the matching boundary. On a discrete grid, this translates into the requirement that the phase field $S(x, t)$ must not change by more than $2 \pi$ between neighbouring grid points at the matching boundary. In other words, we must resolve the de Broglie wavelength at the matching boundary in order for the reverse boundary matching problem to admit a unique solution. This immediately shows that a useful hybrid scheme based on this approach necessarily requires an AMR algorithm with at least two refinement levels for the phase equation: An outer refinement level where the grids need not resolve the de Broglie wavelength and a second refinement level where the de Broglie wavelength is resolved and the reverse boundary matching problem has a unique solution.

## Implementation
We evolve the continuity equation using a first-order upwind scheme (`HYBRID_UPWIND`), the second-order Fromm scheme without limiter (`HYBRID_FROMM`) or a MUSCL scheme with a linear subgrid model together with the van Albada limiter (`HYBRID_MUSCL`). As for the HJ scheme, we use a finite difference scheme. The convection term is discretised via the Sethian-Osher flux. The velocities at the cell faces are then computed as regular finite differences. We treat the cell averages $\bar{\rho}$ in the finite volume scheme as point values $\rho$ in the discretisation of the quantum pressure term. Technically, we use the MUSCL scheme as a conservative finite-difference method and not as a finite volume scheme. This has the consequence that the maximum order of accuracy we can reach with the linear subgrid MUSCL scheme is second order. The quantum pressure term is discretised as
We evolve the continuity equation using a first-order upwind scheme (`UPWIND`), the second-order Fromm scheme without limiter (`FROMM`) or a MUSCL scheme with a linear subgrid model together with the van Albada limiter (`MUSCL`). As for the HJ scheme, we use a finite difference scheme. The convection term is discretised via the Sethian-Osher flux. The velocities at the cell faces are then computed as regular finite differences. We treat the cell averages $\bar{\rho}$ in the finite volume scheme as point values $\rho$ in the discretisation of the quantum pressure term. Technically, we use the MUSCL scheme as a conservative finite-difference method and not as a finite volume scheme. This has the consequence that the maximum order of accuracy we can reach with the linear subgrid MUSCL scheme is second order. The quantum pressure term is discretised as
$$\frac{\Delta \sqrt{\rho}}{\sqrt{\rho}} = \left(\frac{1}{2} \Delta \log(\rho) + \frac{1}{4} \left(\nabla \log(\rho)\right)^2\right)$$
with second-order central finite differences for both the gradient operator and the Laplacian.
The resulting semi-discrete scheme is discretised with a third-order RK method. A second-order discretisation also works well, but requires a more stringent CFL condition.
Expand Down
26 changes: 13 additions & 13 deletions doc/wiki/ELBDM-related/ELBDM-Spectral-Solver.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
## Setup and Configuration

### Compilation Options
- **Wave Scheme Selection**: To enable the spectral solver, set `WAVE_SCHEME` to `WAVE_GRAMFE` in the Makefile or configure with `--wave_scheme=WAVE_GRAMFE` for the ELBDM model.
- **Spectral Scheme Options**: Choose between `GRAMFE_MATMUL` (faster for `PATCH_SIZE=8`) and `GRAMFE_FFT` (faster for larger patch sizes) by setting `GRAMFE_SCHEME` in the Makefile or configure with `--gramfe_scheme` accordingly.
- **Additional Libraries**: The CPU version requires FFTW 3 for single precision and FFTW 2/3 for double precision. The GPU version of `GRAMFE_FFT` needs the cuFFTDx library. Set `FFTW2_PATH`, `FFTW3_PATH`, and `CUFFTDX_PATH` in the Makefile or configuration files `*.config`.
- **Wave Scheme Selection**: To enable the spectral solver, set `WAVE_SCHEME` to `WAVE_GRAMFE` in the Makefile or configure with `--wave_scheme=GRAMFE` for the ELBDM model.
- **Spectral Scheme Options**: Choose between `MATMUL` (faster for `PATCH_SIZE=8`) and `FFT` (faster for larger patch sizes) by setting `SCHEME` in the Makefile or configure with `--gramfe_scheme` accordingly.
- **Additional Libraries**: The CPU version requires FFTW 3 for single precision and FFTW 2/3 for double precision. The GPU version of `FFT` needs the cuFFTDx library. Set `FFTW2_PATH`, `FFTW3_PATH`, and `CUFFTDX_PATH` in the Makefile or configuration files `*.config`.

### Precision and Performance Options
- **Floating Point Precision**: Controlled by `GRAMFE_ENABLE_SINGLE_PRECISION`. The default is double precision. Single precision is not recommended due to stability issues.
Expand Down Expand Up @@ -68,29 +68,29 @@
4. **Avoidance of Gibbs Phenomenon**: Smooth extensions largely prevent the Gibbs phenomenon.
5. **Discarding Extended Domain**: After computation, the extended domain is discarded.

## Differences between GRAMFE_MATMUL and GRAMFE_FFT Schemes
## Differences between MATMUL and FFT Schemes

### Overview
Understanding the differences between the `GRAMFE_MATMUL` and `GRAMFE_FFT` schemes in GAMER is crucial for users to choose the appropriate method for their specific simulation needs. Both schemes are based on the Gram-Fourier extension algorithm but differ in their computational approach and performance characteristics.
Understanding the differences between the `MATMUL` and `FFT` schemes in GAMER is crucial for users to choose the appropriate method for their specific simulation needs. Both schemes are based on the Gram-Fourier extension algorithm but differ in their computational approach and performance characteristics.

### GRAMFE_MATMUL Scheme
### MATMUL Scheme

#### Description
- **Matrix Multiplication Approach**: In the `GRAMFE_MATMUL` scheme, the entire operation sequence - GramFE extension, FFT, time evolution, IFFT, and discarding of extension data - is precomputed and represented as a single matrix (which is possible because of linearity).
- **Matrix Multiplication Approach**: In the `MATMUL` scheme, the entire operation sequence - GramFE extension, FFT, time evolution, IFFT, and discarding of extension data - is precomputed and represented as a single matrix (which is possible because of linearity).
- **Application to Input Vectors**: This precomputed matrix can be directly applied to input vectors, eliminating the need to compute each operation at runtime.

#### Advantages
- **Reduced Runtime Computation**: By precomputing the entire operation sequence, the `GRAMFE_MATMUL` scheme minimizes runtime computational overhead.
- **Reduced Runtime Computation**: By precomputing the entire operation sequence, the `MATMUL` scheme minimizes runtime computational overhead.
- **Efficiency for Small Patch Sizes**: This scheme is particularly efficient for smaller data sizes where the cost of matrix multiplication is lower.

#### Disadvantages
- **Memory Usage**: The precomputed matrix, especially for large patch sizes, can consume significant memory resources.
- **Precomputation Time**: There is an upfront cost in time to compute and store the matrix, which might be substantial depending on the accuracy used.

### GRAMFE_FFT Scheme
### FFT Scheme

#### Description
- **Runtime Computation**: The `GRAMFE_FFT` scheme performs the GramFE extension, FFT, time evolution, IFFT, and discarding of extension data operations at runtime.
- **Runtime Computation**: The `FFT` scheme performs the GramFE extension, FFT, time evolution, IFFT, and discarding of extension data operations at runtime.

#### Advantages
- **Scalability for Large Patch Sizes**: This scheme is more scalable for larger patch sizes, as it does not require storing large precomputed matrices.
Expand All @@ -100,10 +100,10 @@ Understanding the differences between the `GRAMFE_MATMUL` and `GRAMFE_FFT` schem
- **Dependence on FFT Performance**: The efficiency of the scheme is closely tied to the performance of the FFT algorithm used.

### Conclusion
- **Choice of Scheme**: By default `GRAMFE_MATMUL` should be used. `GRAMFE_FFT` should be considered for larger patch sizes and debugging.
- **Choice of Scheme**: By default `MATMUL` should be used. `FFT` should be considered for larger patch sizes and debugging.

## Performance Metrics
- The performance ratio `Perf_FD / Perf_Spectral` indicates the efficiency compared to the finite-difference scheme. This varies based on patch size (e.g., 4.3 for `PATCH_SIZE=8` and 2.6 for `PATCH_SIZE=16` for `GRAMFE_FFT`; comparable performance of `GRAMFE_MATMUL` and `WAVE_FD` for `PATCH_SIZE=8`).
- The performance ratio `Perf_FD / Perf_Spectral` indicates the efficiency compared to the finite-difference scheme. This varies based on patch size (e.g., 4.3 for `PATCH_SIZE=8` and 2.6 for `PATCH_SIZE=16` for `FFT`; comparable performance of `MATMUL` and `FD` for `PATCH_SIZE=8`).

## Issues and Considerations
- **Stability with Single Precision**: Using single precision can lead to instability in the scheme.
Expand All @@ -119,7 +119,7 @@ Understanding the differences between the `GRAMFE_MATMUL` and `GRAMFE_FFT` schem

#### Current Precision and Limitations

The calculation of the evolution matrix in the `GRAMFE_MATMUL` scheme currently requires at least 128-bit precision to maintain an error below single precision. The extension matrix has a high condition number, typically around 10^15 or higher, which necessitates this high precision.
The calculation of the evolution matrix in the `MATMUL` scheme currently requires at least 128-bit precision to maintain an error below single precision. The extension matrix has a high condition number, typically around 10^15 or higher, which necessitates this high precision.

#### Proposed Enhancements

Expand Down
Loading