PredictiveIntelligenceLab / jaxpi

Other
231 stars 52 forks source link

Inquiry about unsteady stokes_cylinder #8

Closed Elappnano closed 6 months ago

Elappnano commented 6 months ago

I am trying to solve unsteady stokes_cylinder, but could not get the desired result. would it be possible to release the code for this example.

Thanks!!

sifanexisted commented 6 months ago

Hello, I am not sure what you mean. Do you mean the current code cannot reproduce the result of that example? Or do you want to use PirateNet for this example?

Elappnano commented 6 months ago

Hi, I am asking if it is possible to produce an example with your library for the unsteady version of the stokes_cylinder example. Thanks.

sifanexisted commented 6 months ago

Isn't ns_unsteady_cylinder the unsteady case?

Elappnano commented 6 months ago

No for stokes the model is different. I tried the base code of the ns_unsteady_cylinder but did not get the desired solution. I could share the code if you are interested.

sifanexisted commented 6 months ago

For Stokes flow, I guess it is supposed to be in a steady state unless a time-dependent inflow condition is given?

Elappnano commented 6 months ago

As a matter of fact, I am working on simulating stokes flow in a micro-fluidics system. In order to get the unsteady phase you should decrease the time-frame to less than 1e-7. I managed to get the desired solution for the steady state using the jax-pi library, but for unsteady state I could not get the desire solution by the library. I would appreciate it if you emailed me at elyasabbasi.2016@gmail.com in order to share the reference solution and the revised code. Thanks

Elappnano commented 6 months ago

Since I did not receive any email, I am going to describe the problem here: In the ns_unsteady_cylinder the last time step of a coarse numerical solution is used as the initial condition. but for my problem I must use the first step as the initial solution, so I changed the time section of the train file to:

    num_time_steps = len(T) // config.training.num_time_windows
    Tt = T[:num_time_steps]

    dt = Tt[1] - Tt[0]
    t0 = Tt[0]
    t1 = (
         Tt[-1] + 2 * dt
     )  # cover the start point of the next time window, which is t_star[num_time_steps]

    temporal_dom = jnp.array([t0, t1])

when the training finished only the first solution predict correctly and the algorithm could not evaluate correctly the solution in other time steps.

sifanexisted commented 6 months ago

How do you get the inital condition for the next time window?

Elappnano commented 6 months ago

I use the following for the first initial condition:

    u0 = u_ref[0, :]
    v0 = v_ref[0, :]
    p0 = p_ref[0, :]

and for the next time steps the inital condition is updated through:


       if config.training.num_time_windows > 1:
            state = jax.device_get(jax.tree_util.tree_map(lambda x: x[0], model.state))
            params = state.params
            u0 = vmap(model.u_net, (None, None, 0, 0))(
                params, T[num_time_steps], coords[:, 0], coords[:, 1]
            )

            v0 = vmap(model.v_net, (None, None, 0, 0))(
                params, T[num_time_steps], coords[:, 0], coords[:, 1]
            )
            p0 = vmap(model.p_net, (None, None, 0, 0))(
                params, T[num_time_steps], coords[:, 0], coords[:, 1]
            )

            del model, state, params
Elappnano commented 6 months ago

after implementing above code, the algorithm predicts the first initial condition correctly but for the next condition the prediction is unsuccessful and weird.