JuliaWaveScattering / MultipleScattering.jl

A Julia library for simulating, processing, and plotting multiple scattering of waves.
Other
45 stars 12 forks source link

Fix time simulations #16

Closed jondea closed 2 years ago

jondea commented 6 years ago

Some thought needs to go into the outer structures for the TimeSimulations again we can obviously reuse a lot of the code which does the mathsy heavy lifting, but we need some motivating examples for the structs. We also need to think about how the TimeSimulations will interact with the random machinery.

arturgower commented 6 years ago

I am unsure if we need a struct TimeSimulations. It is nice to have a struct where the impulse and source functions are in time. Drawbacks and a positive are:

arturgower commented 6 years ago

Have implemented my first suggestion: run(FrequencySimulation, x_vec; ts = time_vec) or run(FrequencySimulation, x_vec, ω_vec; result_in_time = true) now returns a TimeSimulationResult. Having something like this would be very practical.

I've also moved the zero frequency response extrapolation to run, which turned out to be simpler and make more sense (then having it in the signal processing part).

jondea commented 6 years ago

I think it is confusing that run(FrequencySimulation,...) sometimes returns a TimeSimulationResult, but I agree the function looks useful. I think a different name would be much clearer, something which communicates run_and_convert_to_time.

We can always have TimeSimulationResult as an optional structure which contains a FrequencySimulation which essentially calls this function.

arturgower commented 2 years ago

I think having different names for the run function, such as run_and_convert... would hurt discoverability, and is not very Julia. If the user is unaware of the type system, they won't mind having a TimeSimulationResult returned to them, as it will be used in exactly the same way as FrequencySimulationResult, i.e. plot(TimeSimulationResult) and TimeSimulationResult.field.

Alternatively, if the user is aware of the type system, I think they will quickly figure out that specifying a time array, such as run(FrequencySimulation, x_vec; ts = time_vec). There is also the function frequency_to_time and time_to_frequency to easily convert between the types.