Open ryancoe opened 5 months ago
We could completely support frequency
in the same way that we support omega
, period
, wavenumber
and wavelength
.
We'd need to:
frequency
attribute to LinearPotentialFlowProblem
and update accordingly
https://github.com/capytaine/capytaine/blob/f5f0b9fb439d9d865adc1c91255b87537b9bbed1/capytaine/bem/problems_and_results.py#L77
and
https://github.com/capytaine/capytaine/blob/f5f0b9fb439d9d865adc1c91255b87537b9bbed1/capytaine/bem/problems_and_results.py#L182cpt.io.xarray.problems_from_dataset
to pass the frequency data to the initialization of LinearPotentialFlow
cpt.io.xarray.assemble_dataset
following the pattern of https://github.com/capytaine/capytaine/blob/f5f0b9fb439d9d865adc1c91255b87537b9bbed1/capytaine/io/xarray.py#L368This fifth case is making the code a bit longer but not more complicated.
But I don't know if it is worth it, given that the conversion from omega is straightforward. I don't remember seeing any paper using the frequency in Hz to plot hydrodynamic data. Do you have any example of usage in the literature that would justify adding it to the code?
Thanks @mancellin! As far as how useful this is, it might be good to let others weigh in. I definitely do present plots like this with frequency in Hz because I find it easier to interpret (no need to divide by $2\pi$ to understand what the dynamics are at, e.g., 5s). It also aligns with the more common presentation of ocean spectra, which I think are most typically in $S(f)$. Maybe @dav-og @cmichelenstrofer @RubendeBruin @salhus and others can say if they feel similarly?
I agree with you @ryancoe
Prof. Salter once chastised me for plotting hydrodynamic coefficients as a function of rad/s..."engineers have a hard time thinking in rad/s...its much easier for them to understand if you plot these in Hz or S"
I don't remember seeing any paper using the frequency in Hz to plot hydrodynamic data. Do you have any example of usage in the literature that would justify adding it to the code?
@mancellin it used to be more common back in the day - the Edinburgh Wave Power Project used seconds extensively (e.g. Pizer - Numerical Modelling of Wave Energy Absorbers:
I guess it really depends on who you are working with. For practical reports and presentations, I always use seconds (like above). When programming or presenting to scientists I usually use rad/s because you are working with radians for phase angles as well. But Hz may be the best (or worst) of both worlds: "easy" to convert to seconds while having a good view of infinite periods (f->0).
@mancellin it used to be more common back in the day - the Edinburgh Wave Power Project used seconds extensively (e.g. Pizer - Numerical Modelling of Wave Energy Absorbers
Well, that is an example of using periods in seconds (already implemented in Capytaine). My question was about frequencies in Hertz.
But if several of you find useful to add that, I won't refuse a PR.
I think the consensus seems to be towards Hz being the best of both worlds..., but I still personally find rad/s quite useful. The dynamic response shows up as a well distributed lobe, it is easier to interpret phases and how it relates to excitations, easy to map it to diff equations, and to Laplace domain, especially for applications where I want to see the resonant peaks, such as controls. Whereas the periods way, plots it the other way round... slow/large waves on the left and fast/short waves on the right....
Again a matter of preference and application...
@mancellin BEM Rosetta seems to switch between these worlds quite quickly and seamlessly. A tighter integration with Rosetta, might be an expedient route.
I often do the following after running the Capytaine solver:
which allows me to more easily make plots with the
x_label
beingFrequency [Hz]
by usingda.plot(x='freq', ...)
, e.g.,Looking at the source (for the first time in a while...), I think this could be handled cleanly in
xarray.py
in two ways:frequency
to thefrequency_keys
-- this would allow the user to formulate problems usingfrequency
in addition to the existing options.https://github.com/capytaine/capytaine/blob/f5f0b9fb439d9d865adc1c91255b87537b9bbed1/capytaine/io/xarray.py#L77
assemble_dataset
function to add thefrequency
coordinate to the results of any problem.I can definitely do 2, and probably do 1 with some guidance. Any thoughts @mancellin?