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

Bug fix for the ControlModel class #16

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions soupy/modeling/controlModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def evalGradientParameter(self,x, mg):
self.problem.evalGradientParameter(x, mg)
self.qoi.grad(PARAMETER,x,tmp)
mg.axpy(1., tmp)
return math.sqrt(mg.inner(tmp))
return math.sqrt(mg.inner(mg))


def evalGradientControl(self,x, mg):
Expand All @@ -192,7 +192,7 @@ def evalGradientControl(self,x, mg):
# print("MIDFIT GRAD: ", tmp.get_local())
mg.axpy(1., tmp)
# print("OVERALL GRAD: ", mg.get_local())
return math.sqrt(mg.inner(tmp))
return math.sqrt(mg.inner(mg))


def setLinearizationPoint(self, x, gauss_newton_approx=False):
Expand Down
4 changes: 2 additions & 2 deletions soupy/test/ptest_meanVarRiskMeasureSAA.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def l2_norm(u,m,z):
return u**2*dl.dx

def qoi_for_testing(u,m,z):
return u**2*dl.dx + dl.exp(m) * dl.inner(dl.grad(u), dl.grad(u))*dl.ds
return u**2*dl.dx + dl.exp(m) * dl.inner(dl.grad(u), dl.grad(u))*dl.ds - dl.inner(z, z)*dl.dx


class TestMeanVarRiskMeasureSAA(unittest.TestCase):
def setUp(self):
self.reltol = 1e-3
self.fdtol = 1e-2
self.delta = 1e-3
self.delta = 1e-4
self.n_wells_per_side = 3
self.nx = 20
self.ny = 20
Expand Down
3 changes: 1 addition & 2 deletions soupy/test/ptest_scipyCostWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
from setupPoissonControlProblem import poisson_control_settings, setupPoissonPDEProblem

def qoi_for_testing(u,m,z):
return u**2*dl.dx + dl.exp(m) * dl.inner(dl.grad(u), dl.grad(u))*dl.ds

return u**2*dl.dx + dl.exp(m) * dl.inner(dl.grad(u), dl.grad(u))*dl.ds - dl.inner(z, z)*dl.dx

def u_boundary(x, on_boundary):
return on_boundary and (x[1] < dl.DOLFIN_EPS or x[1] > 1.0 - dl.DOLFIN_EPS)
Expand Down
4 changes: 2 additions & 2 deletions soupy/test/ptest_superquantileSAA.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def l2_norm(u,m,z):
return u**2*dl.dx

def qoi_for_testing(u,m,z):
return u**2*dl.dx + dl.exp(m) * dl.inner(dl.grad(u), dl.grad(u))*dl.ds
return u**2*dl.dx + dl.exp(m) * dl.inner(dl.grad(u), dl.grad(u))*dl.ds - dl.inner(z, z)*dl.dx


class TestSuperquantileSAA(unittest.TestCase):
Expand All @@ -73,7 +73,7 @@ class TestSuperquantileSAA(unittest.TestCase):
def setUp(self):
self.reltol = 1e-3
self.fdtol = 1e-2
self.delta = 1e-3
self.delta = 1e-4
self.n_wells_per_side = 3
self.nx = 20
self.ny = 20
Expand Down
Loading