diff comparison from last pull request#8
diff comparison from last pull request#8HopeBestWorld wants to merge 397 commits intobranch-after-pr6from
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
README.md
Outdated
| ## Installation | ||
| 1. **Install the package:** | ||
| ```bash | ||
| pip install git+[https://github.com/symbiotic-engineering/semi-analytical-hydro.git](https://github.com/symbiotic-engineering/semi-analytical-hydro.git) |
There was a problem hiding this comment.
Shouldn't this be open flash now that it's on pypi?
README.md
Outdated
| ## References | ||
|
|
||
| ### Install from the `CS_group` Branch | ||
| The following publications are relevant to this package: |
There was a problem hiding this comment.
Add citations for the JOSS paper and the JFM paper (without writing JOSS or JFM since they haven't accepted it yet), you can add our names and the title and say "in prep", see the MDOcean readme as example
docs/constants.rst
Outdated
| .. autodata:: m0 | ||
| :annotation: = 1 | ||
|
|
||
| Radial wave number. |
There was a problem hiding this comment.
Just called "wavenumber", more often denoted with k
There was a problem hiding this comment.
to be consistent with your description of omega, it's "wavenumber of the incident wave in 1/m"
docs/constants.rst
Outdated
| Radial wave number. | ||
|
|
||
| .. autodata:: n | ||
| :annotation: = 3 |
docs/constants.rst
Outdated
| Related to a mode or term index. | ||
|
|
||
| .. autodata:: z | ||
| :annotation: = 6 |
package/src/meem_engine.py
Outdated
| # Convert the complex number to a dictionary | ||
| hydro_p_terms[i,j] = 0 | ||
|
|
||
| # Now return per-mode values |
There was a problem hiding this comment.
we have previously used mode to refer to the harmonics of the m_k's, but here mode means the mode of motion / degree of freedom. Clarify the difference in comments, or perhaps rename mode to dof here.
package/src/meem_engine.py
Outdated
| imag_coeffs = np.zeros(num_modes) | ||
|
|
||
| for mode_index in range(num_modes): | ||
| if mode_index < hydro_h_terms.shape[0] and mode_index < hydro_p_terms.shape[0]: |
There was a problem hiding this comment.
why is this conditional necessary? add comment, I don't remember why this would be the case. Would hydro_h_terms.shape[0] and hydro_p_terms.shape[0] ever be different?
package/src/meem_engine.py
Outdated
| plt.show() # final display command | ||
|
|
||
| def run_and_store_results(self, problem_index: int, m0) -> Results: | ||
| def run_and_store_results(self, problem_index: int, m0_values: np.ndarray) -> 'Results': |
There was a problem hiding this comment.
use from __future__ import annotations so you can type with Results (no string) even before it's defined
package/src/meem_engine.py
Outdated
| def run_and_store_results(self, problem_index: int, m0_values: np.ndarray) -> 'Results': | ||
| """ | ||
| Perform the full MEEM computation and store results in the Results class. | ||
| Perform the full MEEM computation for a *list of frequencies* and store results |
package/src/meem_engine.py
Outdated
| freq_idx_in_problem = freq_to_idx.get(m0) | ||
| if freq_idx_in_problem is None: | ||
| # This should ideally not happen if m0_values are a subset of problem.frequencies | ||
| print(f" Warning: m0={m0:.4f} not found in problem.frequencies. Skipping calculation.") |
There was a problem hiding this comment.
seems like the code structure should be tweaked so this is not a possibility: either problem.frequencies or m0_values is used but not both. My preference would be problem.frequencies
There was a problem hiding this comment.
If we need to extract m0_values for some reason ie plottng, extract it from problem.frequencies so it's consistent
package/src/multi_equations.py
Outdated
|
|
||
| constant = - heaving[i] * a[i]/(2 * (h - d[i])) | ||
| if k == 0: | ||
| if m0 * h < 14: |
There was a problem hiding this comment.
use M0_H_THRESH=14 or similar constant definition so it can be changed
package/src/multi_equations.py
Outdated
| # ensure r_array doesn't contain 0 if R_2n is called for r=0 | ||
| return 0.5 * np.log(r_array / a[i]) | ||
| else: | ||
| return besselk(0, lambda_ni(n, i, h, d) * r_array) / besselk(0, lambda_ni(n, i, h, d) * local_scale[i]) |
There was a problem hiding this comment.
don't you need a value error if n<0 here like you have above?
package/src/multi_equations.py
Outdated
| def Z_k_e_vectorized(k, z_array, m0, h, NMK, m_k_arr): # Changed 'z' to 'z_array' | ||
| local_m_k = m_k(NMK, m0, h) | ||
| if k == 0: | ||
| if m0 * h < 14: |
There was a problem hiding this comment.
use same const as suggested above
There was a problem hiding this comment.
This has wrong eqns in it, but not a worry because it will be deleted and the multi equations is correct
There was a problem hiding this comment.
delete this too since two-cylinder only
docs/constants.rst
Outdated
| Below are the constants defined in this module: | ||
|
|
||
| mass = 5.0 # Example mass in kg | ||
| .. autodata:: g |
There was a problem hiding this comment.
use the constant g and rho so the user doesn't have to specify them, and can override them if they wish. Other constants like m0, geometry, etc should not go in constants, it's when they create the problem, so delete them from here.
docs/equations.rst
Outdated
| .. autofunction:: lambda_n2 | ||
| :noindex: | ||
|
|
||
| Calculates the eigenvalue :math:`\lambda_n` for the middle fluid domain (Region 2). |
There was a problem hiding this comment.
Not relevant since deleting.
package/src/meem_engine.py
Outdated
| if bd == 0: # One cylinder case (Inner-Exterior directly) | ||
| for n in range(N_left): # Inner harmonics (N) | ||
| A[row_offset + n][col_offset + n] = (h - d[bd]) * R_1n(n, a[bd], bd, h, d, a) | ||
| for m in range(M_right): # Exterior harmonics (K) |
There was a problem hiding this comment.
This is fixed in multi_MEEM notebook. Transfer this fix over to equations instead of engine.
package/src/geometry.py
Outdated
| @@ -57,7 +57,7 @@ def make_domain_list(self) -> Dict[int, 'Domain']: | |||
| 'h': h, | |||
There was a problem hiding this comment.
don't allow h, di, and a to be independently passed domain params, but the geometry should auto create the domain objects with these properties so it's consistent.
There was a problem hiding this comment.
We want Bimali's functions to discretize the slant in different ways (left, right center, etc) as methods of geometry that it uses when turning r,z coordinates (of the body, representing a curve or other non MEEM supported thing) into a list of domains
There was a problem hiding this comment.
we want geometry (not problem as in the UML diagram) to have a property that is a logical array, of size num_domains x num_domains, saying whether a domain is next to each other domain.
package/test/meem_engine_example.py
Outdated
| all_potentials_batch_data = [] # <--- NEW: List to store potential data for all frequencies/modes | ||
|
|
||
| print("\n--- Starting Batch Processing for Multiple Frequencies ---") | ||
| for i, current_m0_val in enumerate(meem_problem.frequencies): |
There was a problem hiding this comment.
have the for loop here not be necessary for the user to do, you can just call engine.solve and it solves all the problems in the list
package/test/meem_engine_example.py
Outdated
|
|
||
| # --- 3. Create a MEEMProblem Instance and set multiple frequencies --- | ||
| meem_problem = MEEMProblem(geometry=geometry) | ||
| meem_problem.set_frequencies_modes(analysis_frequencies, analysis_modes) |
There was a problem hiding this comment.
analysis modes is redudant
package/src/meem_engine.py
Outdated
| #AttributeError: 'Domain' object has no attribute 'r_coordinates' | ||
| #'r': domain.r_coordinates, | ||
| #'z': domain.z_coordinates | ||
| 'r': geometry_instance.r_coordinates, |
There was a problem hiding this comment.
Users should be able to pass a desired r/z vector for visualization (or maybe just a resolution and we create it based on the geometry)
package/test/meem_engine_example.py
Outdated
| damping_matrix = np.array(collected_damping).reshape(num_frequencies, num_modes) | ||
|
|
||
| # --- 7. Instantiate Results and Store Data --- | ||
| results_obj = Results(geometry, frequencies_for_results, modes_for_results) |
There was a problem hiding this comment.
use the method that creates results for you, instead of creating it yourself
package/test/main_test.py
Outdated
| problem_cache = engine.cache_list[problem] # Access the existing cache | ||
|
|
||
| if problem_cache is None: | ||
| print("ERROR: problem_cache is None!") |
There was a problem hiding this comment.
should this be an actual error?
package/test/meem_engine_example.py
Outdated
| 'data': formatted_potentials_for_batch | ||
| }) | ||
|
|
||
| except np.linalg.LinAlgError as e: |
There was a problem hiding this comment.
error handling should happen in the meem engine, not the test
There was a problem hiding this comment.
Shouldn't this test, in addition to doing mocks, also test that the actual results for the non-first (cached) problem are the same as that problem evaluated without any caching (using the original _full method)
pyproject.toml
Outdated
| "Intended Audience :: Science/Research", | ||
| "Topic :: Scientific/Engineering :: Physics", | ||
| ] | ||
| dependencies = [ |
There was a problem hiding this comment.
instead of super specific versions and all packages from an env export, this should be a minimal list of dependencies with inequalities
requirements.txt
Outdated
There was a problem hiding this comment.
see comment on pyproject.toml
There was a problem hiding this comment.
great high level walkthrough, can we also include a plot of the hydro coeffs vs omega here?
The previous implementation of `run_and_store_results` was flawed. It
solved for a single combined potential (all bodies heaving at once) and
incorrectly tried to reshape the resulting 1xN force vector into an
NxN matrix. This caused a `ValueError` for multi-body problems.
This commit refactors the `run_and_store_results` method to correctly
solve the N-body radiation problem:
- It now loops through each frequency *and* each radiating mode `i`.
- For each mode `i`, it creates a temporary `MEEMProblem` where only
body `i` is heaving, and solves for its unique potential ($X_i$).
- It then calculates the forces on all bodies `j` resulting from
this potential, correctly building the `i`-th column of the
hydrodynamic matrices ($A_{ji}$, $B_{ji}$).
- This correctly assembles the full NxN added mass and damping matrices.
- Potentials are now stored correctly, saving the actual computed
coefficients ($C_s$) for each radiation problem instead of random data.
Correspondingly, `app.py` is reverted to remove the inefficient
manual-looping workaround. It now makes a single, clean call to the
fixed `run_and_store_results` method.
This commit addresses two separate issues:
1. Corrects a `NameError` typo in `meem_engine.py`.
- `diff_Z_n_i_vectorGized` has been renamed to
`diff_Z_n_i_vectorized` inside the `calculate_velocities`
method.
2. Updates `test_run_and_store_results` to correctly
calculate the expected shape of the stored potentials.
- The test now accounts for intermediate domains storing `2 * NMK`
coefficients (for both $R_{1n}$ and $R_{2n}$ components),
rather than just `NMK`.
- This aligns the test's assertion with the engine's correct
storage behavior, resolving the `AssertionError`.
Correct N-body radiation solve in run_and_store_results
updated package and reuploaded it to pypi
updating the streamlit app deployment
…flows/deploy-docs.yml file
the new app.html location, the conf.py edit, and the new .github/work…
installing requirements
installing open-flash
…s. Updates the CI workflow to install dependencies using pip install -e .[dev], ensuring the CI environment matches the configuration in pyproject.toml.
Updates build configurations, documentation, and CI/CD workflows to rely on pyproject.toml extras instead of the deprecated requirements.txt. - MANIFEST.in: Stop including requirements.txt. - deploy-docs.yml: Install dependencies via pip install .[dev]. - README.md: Update developer installation instructions. - installation.rst: Update troubleshooting steps.
Removes requirements.txt to eliminate redundant dependency definition…
- Updated tutorial_walk.ipynb to split the simulation into two separate cases (inner body heaving, then outer body heaving). This resolves the heaving_count <= 1 assertion error caused by setting multiple bodies to heave simultaneously before the coupling matrix is implemented. - Added package/test/test_tutorial.py to execute the tutorial notebook in CI, ensuring future regressions are caught automatically.
- Modified Results class in package/src/openflash/results.py to accept an optional modes argument. This allows pre-allocating result matrices for the full system (e.g., 2 modes) even when the problem instance only has one active mode. - Enhanced tutorial to demonstrate manual aggregation of hydrodynamic coefficients from separate mode simulations into a single Results dataset. - Added potential field visualization and domain inspection steps to the tutorial.
- Added `test_results_initialization_with_explicit_modes` to `package/test/test_results.py`. - This test verifies that passing a specific list of modes to the `Results` constructor correctly sets the `modes` attribute and updates the xarray dataset coordinates, ensuring coverage for the `if modes is not None:` initialization branch.
Fix tutorial notebook and add test
- Updated MEEMEngine.run_and_store_results to extract excitation_force and excitation_phase from the solver output and pass them to the results object. - Updated Results.store_hydrodynamic_coefficients to accept and store these new excitation metrics in the xarray dataset. - Fixed type hint in Results to allow Optional[np.ndarray] for optional arguments, resolving static analysis errors. - Fixed type hint in ProblemCache to correctly reflect that I_nm_vals is a List[np.ndarray]. - Fixed OpenFLASH.ipynb visualization by correctly importing matplotlib.patches for drawing geometry rectangles.
capture excitation force/phase and fix type hints
- Added package/test/test_matrix_verification.py to systematically generate matrix sparsity plots for all test configurations (config0-config6). - Included structural assertions (square matrix, correct dimensions based on harmonics). - Included numerical health checks (NaN/Inf detection, condition number warning, singularity check). - Implemented safe_heaving_map logic to bypass ConcentricBodyGroup assertion (single heaving body limit) during matrix assembly, as the system matrix A is independent of the heaving state.
Add matrix verification test suite for all configs
…_2n, Z_n, Lambda_k, Z_k, and their derivatives). This ensures that passing a Python list (as meem_engine.py does) will no longer crash the math operations
delete non vectorized functions
- Vectorized in to use block operations for potential and velocity matching, replacing O(N*M) element-wise loops. - Fixed a closure scope bug in by implementing a factory function () to strictly bind derivative vectors
adding benchmark test comparing accuracy, memory, convergence, runtim…
No description provided.