In [11]:
import sympy as sy
from dolfin import *

In [ ]:


In [ ]:


In [4]:
x = sy.symbols('x')
y = sy.symbols('y')
G = sy.symbols('G')
Ha = sy.symbols('Ha')
nu = sy.symbols('nu')
kappa = sy.symbols('kappa')

In [ ]:


In [ ]:
sy.ccode

In [16]:
b = G/kappa*(sy.sinh(y*Ha)/sy.sinh(Ha)-y)
d = 1
p = -G*x - (kappa/2)*b1**2
u = G/(nu*Ha*sy.tanh(Ha))*(1-sy.cosh(y*Ha)/sy.cosh(Ha))
v = sy.diff(x,y)
L1 = sy.diff(u,x,x)+sy.diff(u,y,y)
L2 = sy.diff(v,x,x)+sy.diff(v,y,y)

A1 = u*sy.diff(u,x)+v*sy.diff(u,y)
A2 = u*sy.diff(v,x)+v*sy.diff(v,y)

P1 = sy.diff(p,x)
P2 = sy.diff(p,y)
C1 = diff(d,x,y) - diff(b,y,y)
C2 = diff(b,x,y) - diff(d,x,x)

In [17]:
v


Out[17]:
0

In [ ]:


In [ ]:


In [18]:
u0 = Expression((sy.ccode(u),sy.ccode(v)))
p0 = Expression(sy.ccode(p))

Laplacian = Expression((sy.ccode(L1),sy.ccode(L2)))
Advection = Expression((sy.ccode(A1),sy.ccode(A2)))
gradPres = Expression((sy.ccode(P1),sy.ccode(P2)))


In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '/Users/michaelwathen/.instant/error/dolfin_compile_code_2c15bce32d452fbe2c8db749d5e09bce897ad400/compile.log'
ERROR:instant:In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '/Users/michaelwathen/.instant/error/dolfin_compile_code_2c15bce32d452fbe2c8db749d5e09bce897ad400/compile.log'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-18-d0b976df1bd6> in <module>()
----> 1 u0 = Expression((sy.ccode(u),sy.ccode(v)))
      2 p0 = Expression(sy.ccode(p))
      3 
      4 Laplacian = Expression((sy.ccode(L1),sy.ccode(L2)))
      5 Advection = Expression((sy.ccode(A1),sy.ccode(A2)))

/Users/michaelwathen/.hashdist/bld/profile/2ik4xg6kjxpj/lib/python2.7/site-packages/dolfin/functions/expression.py in __new__(cls, cppcode, element, cell, domain, degree, name, label, mpi_comm, **kwargs)
    600         cpp_base, members = compile_expressions([cppcode],
    601                                                 [generic_function_members], \
--> 602                                                 mpi_comm=mpi_comm)
    603         cpp_base, members = cpp_base[0], members[0]
    604 

/Users/michaelwathen/.hashdist/bld/profile/2ik4xg6kjxpj/lib/python2.7/site-packages/dolfin/compilemodules/expressions.py in compile_expressions(cppargs, generic_function_members, mpi_comm)
    215         code_snippets), classnames, additional_declarations="\n".join(\
    216                                                      additional_declarations),
--> 217                                                  mpi_comm=mpi_comm)
    218 
    219     return expression_classes, all_members

/Users/michaelwathen/.hashdist/bld/profile/2ik4xg6kjxpj/lib/python2.7/site-packages/dolfin/compilemodules/expressions.py in compile_expression_code(code, classnames, module_name, additional_declarations, mpi_comm)
    143     compiled_module = compile_extension_module(\
    144         code, additional_declarations=additional_declarations, \
--> 145         mpi_comm=mpi_comm)
    146 
    147     # Get the compiled class

/Users/michaelwathen/.hashdist/bld/profile/2ik4xg6kjxpj/lib/python2.7/site-packages/dolfin/compilemodules/jit.py in mpi_jit(*args, **kwargs)
     62         # Just call JIT compiler when running in serial
     63         if MPI.size(mpi_comm) == 1:
---> 64             return local_jit(*args, **kwargs)
     65 
     66         # Compile first on process 0

/Users/michaelwathen/.hashdist/bld/profile/2ik4xg6kjxpj/lib/python2.7/site-packages/dolfin/compilemodules/compilemodule.py in compile_extension_module(code, module_name, additional_declarations, additional_system_headers, mpi_comm, **instant_kwargs)
    456         code              = code,
    457         additional_declarations = _additional_declarations % declaration_strs,
--> 458         **instant_kwargs)
    459 
    460     sys.stdout.flush()

/Users/michaelwathen/.hashdist/bld/profile/2ik4xg6kjxpj/lib/python2.7/site-packages/instant/build.pyc in build_module(modulename, source_directory, code, init_code, additional_definitions, additional_declarations, sources, wrap_headers, local_headers, system_headers, include_dirs, library_dirs, libraries, swigargs, swig_include_dirs, cppargs, lddargs, object_files, arrays, generate_interface, generate_setup, cmake_packages, signature, cache_dir)
    561 
    562         # Recompile if necessary
--> 563         recompile(modulename, module_path, new_compilation_checksum, build_system)
    564 
    565         # --- Load, cache, and return module

/Users/michaelwathen/.hashdist/bld/profile/2ik4xg6kjxpj/lib/python2.7/site-packages/instant/build.pyc in recompile(modulename, module_path, new_compilation_checksum, build_system)
    163                     os.remove(compilation_checksum_filename)
    164                 msg = "In instant.recompile: The module did not compile with command '%s', see '%s'"
--> 165                 instant_error(msg % (cmd, compile_log_filename_dest))
    166 
    167     finally:

/Users/michaelwathen/.hashdist/bld/profile/2ik4xg6kjxpj/lib/python2.7/site-packages/instant/output.pyc in instant_error(*message)
     83     _log.error(*message)
     84     text = message[0] % message[1:]
---> 85     raise RuntimeError(text)
     86 
     87 def instant_assert(condition, *message):

RuntimeError: In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '/Users/michaelwathen/.instant/error/dolfin_compile_code_2c15bce32d452fbe2c8db749d5e09bce897ad400/compile.log'

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [11]:
sy.diff(b,y)


Out[11]:
G*(Ha*cosh(Ha*y)/sinh(Ha) - 1)/kappa

In [18]:
p = -G*x - (kappa/2)*b**2
p


Out[18]:
-G**2*(-y + sinh(Ha*y)/sinh(Ha))**2/(2*kappa) - G*x

In [19]:
sy.diff(p,x)


Out[19]:
-G

In [20]:
sy.diff(p,y)


Out[20]:
-G**2*(-y + sinh(Ha*y)/sinh(Ha))*(2*Ha*cosh(Ha*y)/sinh(Ha) - 2)/(2*kappa)

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: