Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregation of the equations on the boundary #363

Open
luAndre00 opened this issue Oct 7, 2024 · 2 comments
Open

Aggregation of the equations on the boundary #363

luAndre00 opened this issue Oct 7, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@luAndre00
Copy link
Contributor

I am trying to solve an optimal control problem constrained with the stokes equation. After writing the Lagrange system of equation I get many boundary conditions:

` def dirichlet1_ad(input_, output_):
return output_.extract(['zx'])

def dirichlet2_ad(input_, output_):
    return output_.extract(['zy'])

def neumann1_ad(input_, output_):
    return -output_.extract(['r']) + 0.1 * grad(output_, input_, components=['zx'], d=['x'])

def neumann2_ad(input_, output_):
    return output_.extract(['zy'])

def dirichlet1(input_, output_):
    return output_.extract(['vx']) - input_.extract(['y'])

def dirichlet2(input_, output_):
    return output_.extract(['vy'])

def neumann1(input_, output_):
    return -output_.extract(['p']) + 0.1 * grad(output_, input_, components=['vx'], d=['x'])

def neumann2(input_, output_):
    return output_.extract(['vy'])`

With

conditions = {
    'gamma_above': Condition(location=CartesianDomain({'x': xrange, 'y': 2, 'mu': murange}),
                             equation=SystemEquation([dirichlet1, dirichlet2, dirichlet1_ad, dirichlet2_ad], reduction = "none")),
    # Dirichlet
    'gamma_left': Condition(location=CartesianDomain({'x': 0, 'y': yrange, 'mu': murange}),
                            equation=SystemEquation([dirichlet1, dirichlet2, dirichlet1_ad, dirichlet2_ad], reduction = "none")),
    # Dirichlet
    'gamma_below': Condition(location=CartesianDomain({'x': xrange, 'y': 0, 'mu': murange}),
                             equation=SystemEquation([dirichlet1, dirichlet2, dirichlet1_ad, dirichlet2_ad], reduction = "none")),
    # Dirichlet
    'gamma_right': Condition(location=CartesianDomain({'x': 1, 'y': yrange, 'mu': murange}),
                             equation=SystemEquation([neumann1, neumann2, neumann1_ad, neumann2_ad], reduction = "none")),  # Neumann
    'D': Condition(location=CartesianDomain({'x': xrange, 'y': yrange, 'mu': murange}),
                   equation=SystemEquation([momentum_x, momentum_y, continuity,
                                            momentum_ad_x, momentum_ad_y, continuity_ad], reduction = "none"))
}

I was wondering if it is correct to define the boundaries as a System of equation with reduction = None, because I have problems on the boundary conditions and I do not understand why.

Another doubt I had concerns the definition of the momentum equation: I wrote them considering one components at a time, so I have momentum_x, momentum_y and not only one equation of the momentum with length 2. The same is true for the momentum of the adjoint variables.
My question is: is it different if I define only one momentum with length 2? Should I get the same results?

Thank you for you help!

@luAndre00 luAndre00 added the help wanted Extra attention is needed label Oct 7, 2024
@dario-coscia
Copy link
Collaborator

Hi! Can you provide in latex form the problem you are trying to solve?
What time of problem you are getting with the boundaries (code error or not converging)?

@luAndre00
Copy link
Contributor Author

$$ \begin{cases} \displaystyle-0.1\Delta z(x,\mu) + \nabla r(x,\mu) = [x_2 - v_1(x,\mu),0]^T \\ \displaystyle\nabla\cdot z(x,\mu) = 0 \\ \displaystyle\alpha u(x,\mu) = z(x,\mu) \\ \displaystyle-0.1\Delta v(x,\mu) + \nabla p(x,\mu) = f(x,\mu) + u(x,\mu) \\ \displaystyle\nabla\cdot v(x,\mu) = 0\\ \displaystyle z_1(x,\mu) = z_2(x,\mu) = 0 \\ \displaystyle v_1(x,\mu) = x_2 \text{and} v_2(x,\mu) = 0 \\ \displaystyle-r(x,\mu) + 0.1\frac{\partial z(x,\mu)}{\partial n} = 0 \text{and} z_2(x,\mu) = 0 \\ \displaystyle-p(x,\mu) + 0.1\frac{\partial v(x,\mu)}{\partial n} = 0 \text{and} v_2(x,\mu) = 0 \end{cases} $$

sorry for some problem of visualization, I don't know how to fix them. Actually at the moment I got a good solution of this problem but I had to use eq 3 to change all z into u and solve the problem not considering z. The reconstruction of z was made after redefining the forward of the net imposing the third equation strongly. The problem I had before was that the boundary conditions were not converging. I don't know if there was something about PINA that I was not considering/out of my knowledge, or if these results (solving with u plus z = bad, solving only using u = good) are totally reasonable.

Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants