-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 21/09/15 10:38, Justin Chang wrote:
Hello again,
I am still having issues with this, what I had done originally was not correct.
In FEniCS, all I had to do was
A_D, b_D = assemble_system(a_D, L_D, bcs_D)
And feed the A_D and b_D terms into scipy's optimization. Essentially I am solving:
min 0.5*x^T*A_D*x - x^T*b_D
and the gradient of the above would be:
A_D*x - b_D
I have attached said FEniCS code (named "Decay_Problem_3.py") which solves a different problem, but the concept is the same.
However, this methodology does not work with my current setup. If I replicate the above in Firedrake, the entire solution seems to be fixated to the dirichlet BCs and whatever initial conditions I have provided, which I am guessing is what you were warning me about previously. Do you guys handle Dirichlet boundary conditions differently than how FEniCS handles theirs? I have also attached my current firedrake code (named "2D_plume_ADR_ex1.py", the parts in question begin at line 161)
Ah, OK. So when you assemble an operator with boundary conditions, the bc rows /and/ columns are zeroed and a 1 is placed on the diagonal. The appropriate RHS for this linear is system is then not just the linear form L_D assembled with the bcs applied. You need to "lift" the boundary conditions from the operator to the RHS. assemble_system does this under the hood for you. I think things will work if you do the following: # I assume the solution space is W A_D = assemble(a_D, bcs=bcs_D) tmp = Function(W) for bc in bcs_D: bc.apply(tmp) rhs_bcs = assemble(action(a_D, tmp)) b_D = assemble(L_D) b_D -= rhs_bcs for bc in bcs_D: bc.apply(b_D) More details on the background here: www.firedrakeproject.org/boundary_conditions.html Cheers, Lawrence -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJV/9K0AAoJECOc1kQ8PEYv0e0H/0OPFWJlgURq0MDdW6322f3I 3lfPOZH8Odlj4sd4XX1+bx9/q2dN9Ob1reWFFWRalVukIS6JsJMG4All07X1ZZwi qyV3j4fZNoucmzf5taaM46EoYNE+IS7COKrfwhMU+jS+erPYL0JdGsZHneUazjet /wt3MrMKt5Njlzw39yVKAMpD7WOXda/568lcEWpdce3nR+tEjhdK92v9DlSt1CdQ /GoiSgmAAc5PHguOqeGcbcXasp4cqvoiyMv5Mehk5gIdwO747c0jruoxQK8Mx3V8 uBkfalDAUOhgMKgllPESD3gFAJbjopx2MbB0W8bEPYz2n4tgb/ZOujqb6ScZfrY= =bVZX -----END PGP SIGNATURE-----