boutproject / BOUT-dev

BOUT++: Plasma fluid finite-difference simulation code in curvilinear coordinate systems
http://boutproject.github.io/
GNU Lesser General Public License v3.0
182 stars 95 forks source link

More simulations #874

Open dschwoerer opened 6 years ago

dschwoerer commented 6 years ago

Is there a good way to run 2 simulations within the same script?

from boutcore import *
init()

class MyModel(PhysicsModel):
    def init(self):
        self.n=create3D("sin(x)")
        self.solve_for(dens=self.n)
    def rhs(self,time):
        self.n.ddt(DDX(self.n))

model=MyModel()
model.init()
model.solve()
# Here we need to do something
model2=MyModel()
model2.init()
model2.solve()

It fails on the second call to MyModel() when tt is added the second time to the datafile It would further probably be useful to change the directory as well ...

d7919 commented 6 years ago

This would be nice to be able to do, and I think was part of the motivation for introducing the class based models. I assume the same thing happens in a pure C++ version?

Do we expect multiple models to have their own datafile or should there be a shared one? The later (which is the current case I think) will have a number of issues such as the one shown, but also there's no promise that the two models will advance the same number of timesteps, will have the same dimensions etc.. so I'm not sure this will be feasible (except perhaps with hdf5). Should the PhysicsModel constructor deal with creating a standalone datafile (unless one passed in)?

dschwoerer commented 6 years ago

I haven't tried the pure C++ version - I just noticed while trying to test several model interface for python. I think though, that it should be the same.

I guess different datafiles should be the default - there might be overlap - but that might be more difficult ...

Further, it would probably be nice to be able to have different setting trees - with the possibility to create them ether from a different .inp or copy a different one and change settings ...

ZedThree commented 6 years ago

We have some funding this year to work on this. The aim will be to enable multiple physics models on multiple meshes that communicate through some overlap region and user-defined handshake average.

I think recent work has got us most of the way there already, so hopefully it won't be a major effort.