amusecode / amuse

Astrophysical Multipurpose Software Environment. This is the main repository for AMUSE
http://www.amusecode.org
Apache License 2.0
155 stars 98 forks source link

Lost connection to Fi when recommitting particles #1014

Open JStroo2000 opened 10 months ago

JStroo2000 commented 10 months ago

When adding new SPF particles to a running Fi hydro code, the code crashes

time = 0|units.yr end_time = 10|units.yr while time <= end_time: time += timestep new_wind = wind.create_wind(star) cloud.add_particles(new_wind) cloud.synchronize_to(hydro.gas_particles) hydro.evolve_model(time) channel_hydro_to_gas.copy() print(time) Error message: CodeException: Exception when calling function 'recommit_particles', of code 'FiInterface', exception was 'lost connection to code'

@GijsVermarien

rieder commented 10 months ago

Can you try starting Fi with hydro = Fi(redirection='none')? The code above can crash for any number of reasons, I can't immediately see what could cause it.

JStroo2000 commented 10 months ago

Can you try starting Fi with hydro = Fi(redirection='none')? The code above can crash for any number of reasons, I can't immediately see what could cause it.

Setting redirection to none gives a 'timestep too small' message, for timesteps up to 1 Myr. It also gives the same error message as above.

rieder commented 10 months ago

Thanks. I’ve seen this error before then, I’ll get back to you soon.

prashant050701 commented 9 months ago

Hello! I am having the same error when I trying to use timestep in yr, it works for timesteps of a few days when the total evolution time is couple of hundred of days but when the evolution time is in hundred of years and timestep is in yr, it gives timestep too small error. Strangely, it also gave me timestep way too small error when I increased the timestep.

rieder commented 9 months ago

Thanks. I’ve seen this error before then, I’ll get back to you soon.

I saw it before in #670. It's probably not the same solution here, but the underlying cause is probably the same.

As a potential workaround, could you try manually setting hydro.parameters.timestep = 1 | units.s, calling hydro.evolve_model(hydro.model_time + (1 | units.s)) and then setting the timestep back to its original value, e.g.:

timestep_old = hydro.parameters.timestep
hydro.parameters.timestep = 1 | units.s
hydro.evolve_model(hydro.model_time + (1 | units.s))
hydro.parameters.timestep = timestep_old
hydro.evolve_model(time)

Please let me know if this works.