Skip to content

Instantly share code, notes, and snippets.

View funsim's full-sized avatar
🌿

Simon Wolfgang Funke funsim

🌿
View GitHub Profile
@funsim
funsim / questions.json
Created November 12, 2011 19:18
Questions
{
"one": "Singular sensation",
"two": "Beady little eyes",
"three": "Little birds pitch by my doorstep"
}
<introduction>
Security is all about attaining an appropriate level of security in an infinite
sea of vulnerability. Every computer system and network is compromizable
given enough time, resources, and motivation, however such resources are
never unlimited, so security becomes about finding the right balance. What
you are reaching for is to raise the bar of your defensive measures at least
high enough that it is not worthwhile for your adversaries to commit the
resources required to breach your security. Therefore this report is about two
things. Firstly determining the optimal place for you to raise your security
capability to such that you put your online activities effectively out of reach
<report>
<introduction>
<description>INTRODUCTION_DESCRIPTION</description>
</introduction>
<advisaries>
<description>ADVISARIES_DESCRIPTION</description>
<general_advisaries>
<subtitle>GENERAL_ADVISARIES_SUBTITLE</subtitle>
<description>GENERAL_ADVISARIES_DESCRIPTION</description>
</general_advisaries>
@funsim
funsim / test.json
Created June 16, 2012 14:53
test.json
{
"firstName": "John",
"lastName" : "Smith",
"age" : 25,
"address" : "..."
}
from dolfin import *
from dolfin_adjoint import *
mesh = RectangleMesh(-1, -1, 1, 1, 20, 20)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V, name="State")
m = Function(V, name="Control")
v = TestFunction(V)
F = (inner(grad(u), grad(v)) - m*v)*dx
""" Solves the mother problem in optimal control of PDEs """
from dolfin import *
from dolfin_adjoint import *
dolfin.set_log_level(ERROR)
dolfin.parameters["optimization"]["test_gradient"] = False
# Define the domain [-1, 1] x [-1, 1]
n = 200
''' Example for solving a nonlinear optimisation problem with time-dependent control.
It solves:
min_{u,m} 1/2 ||u(t=T)-u_d(t=T)||^2
subject to:
\grad u/\grad t - \nabla^2 u + u^3 = m,
running build_ext
building '_instant_module_81cc3b239b71f9e22c25de888db576b6854f0f33' extension
creating build
creating build/temp.linux-x86_64-2.7
mpicc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/lib/python2.7/dist-packages/petsc/include -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c mat_utils.cxx -o build/temp.linux-x86_64-2.7/mat_utils.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
mpicc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/lib/python2.7/dist-packages/petsc/include -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c instant_module_81cc3b239b71f9e22c25de888db576b6854f0f33_wrap.cxx -o build/temp.linux-x86_64-2.7/instant_module_81cc3b239b71f9e22c25de888db576b6854f0f33_wrap.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enable
from opentidalfarm import *
class ADDolfinExpression(object):
def element_order(self, V):
''' Returns the element polynomial order '''
return TestFunction(V).element().degree()
def __init__(self, f):
self.f = f
order = self.element_order(f.function_space())
from dolfin import *
mesh = UnitSquareMesh(2, 2)
V = FunctionSpace(mesh, "CG", 2)
f = project(Expression("sin(x[1]) * cos(x[0])"), V)
File("f.xyz") << f