JuliaWaveScattering / MultipleScattering.jl

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

Source should have a field medium #26

Closed arturgower closed 4 years ago

arturgower commented 4 years ago

At present Source only has the fields coef and field. This leads to some problems, first it means that the constructor is used in the form FrequencySimulation(medium, particles, source), because Source has forgotten its medium. This then also allows us to do nonsense like this:

source_medium = Acoustic(2.0, 2.0, 2)
medium = Acoustic(1.0, 1.0, 2)
source = plane_source(medium)
simulation = FrequencySimulation(medium, source)

If we had particles, then this would lead to non-sense results. The constructor FrequencySimulation should never have the freedom to choose a medium which is different from the Source.

arturgower commented 4 years ago

This led to quite a few simplifications. The need for the type FrequencySimulation is not so obvious anymore. Still, no current plans to restructure this.

jondea commented 4 years ago

I know you've made this change already, but I was wondering: why is it natural for the background medium to be stored in the source? Why not provide it separately (or even bundle it up with the Particles in some kind of Domain object) and pass into the source during the simulation?

arturgower commented 4 years ago

The background medium is semantically part of the source, it is the medium the source travels in. As shown above, separating it actually allows for nonsense simulations (a source being used in the wrong medium). Also it turns out that almost everywhere we needed source we also needed the source medium, so it made things simpler to have source have a field medium.