Friday, June 25, 2010

Week June 20 -- June 25

This week I implemented a Dirac solver in 1D, I have it in my private branch and I'll get a permission at the end of the summer to get it opensourced. Originally it didn't work at all, but then I've found a bug and it seems to be working now.

Before it I've implemented an example for the y''+k^2*y=0 equation in hermes1d by writing it as two coupled first order equations and solving the eigenproblem for "k".

I also started to implement a Function class that represents a function in 1D using Fekete points and I plan to implement orthogonal projections and adaptive algorithms for refining the mesh, so that I can play with adaptivity in 1D.

Besides that I studied couple articles about using b-splines to solve the radial Dirac equation and also about using variational formulation for FEM.

I helped fix hermes_common and did lots of administration at the lab (10 online courses and other things). We also got an awesome NIF tour.

Hermes1D patches:

Ondrej Certik (26):
Remove the autogenerated Makefile
hermes_common updated
Dirac solver added
Plot only 10 eigenfunctions
Fix the number of equations bug
Generate the Gauss Lobatto points
Add the autogenerated file
Don't use strings as dict keys
Fekete points manipulation implemented
fekete: solve the coefficients, tests pass
More tests added
system_sin_eigen example added
Add a comment about the Lagrange interpolation
Function.project_onto() implemented
Function.plot() implemented
Comparisons implemented
Fix precision problems
Improve tests
Start implementing the adaptivity
fekete: add a debug code
Removing the Dirac solver for now
Use smaller basis, while still getting reasonable results
Add harmonic oscillator option
hermes_common updated
Use jsplot if it is available
Better demo

hermes_common patches:

Ondrej Certik (6):
Revert "fixed pxd"
Update the generated .cpp file
Increase the precision in tests to 10^-10
Add tests for solve_linear_system_dense_lu()
Enable scipy tests
Test for solve_linear_system_cg() added

Friday, June 18, 2010

June 12 -- June 18

This week I have implemented a JSPlot library, which allows to use matplotlib API, but plot into your web browser:
(Scroll down a little bit to see the screenshots and examples.)

This was the last missing piece to be able to develop with FEMhub (I don't have a root access to my computer, running RHEL5). Now I have the full Python stack working (scipy, all the solvers, mayavi, ...), plus nice plotting in the browser.

I have spent several days investigating how to write weak forms for the radial Dirac equation as well as how to derive the action for it. It turns out, that one takes the Lagrangian from quantum electrodynamics (QED), converts it to spherical coordinates (which you can imagine is a hell of a job) and then integrates over angles and what remains is the Lagrangian (resp. action) for the radial Dirac equation. People used that in the literature a lot, but I just could not figure out where they take the functional from. So that part is clear and then I went to coding.

Here are the commits for JSPlot:

Ondrej Certik (38):
Initial commit
Make index.html work
README added
Hook up raphael
Serve raphael-min.js locally
Plot simpler stuff
Works fine
plots work
Download all the raphael stuff locally
raphael.html added
Use {% url %}
Use simpler urls
Typo fix
Flotr demo added
Use flotr in the index page
Don't recalculate
Add data by hand
Generate the data in Python
Add another flotr demo
Example mpl plot added
jsplot example added added
Hook it up with jsplot
Add a screenshot
Better README added
README improved
Show some testing data
Use better testing data
License added added
Use testing data if data == []
Just return from the function on CTRL-C
spkg-install added
prepend the .. path, instead of append
Use the proper local files in ./
Turn off points
Fix a bug
Add grid and legend

I fixed some scipy warnings in hermes2d:

ondrej@crow:~/repos/hermes2d(master)$ git weekreport
Ondrej Certik (4):
hermes_common updated
Fix the other SciPy warning in Python wrappers
Update the generated .cpp file
update hermes_common

I have fixed Python wrappers in hermes1d, made the Schroedinger example work again:

ondrej@crow:~/repos/hermes1d(master)$ git weekreport
Ondrej Certik (19):
Use jsplot if available
Build everything for now
Make the Python wrappers work again
Fix the lhs/rhs/residual to build properly
Polish the forms a little bit
Enable assembling
Implement c2py_Mesh
Use c2py_Mesh in the schroedinger example
Update insert_matrix in Schroedinger
Fixed the rest in Schroedinger
copy_mesh_to_vector() and copy_vector_to_mesh() added to the Mesh class
Use JSPlot
Linearizer.get_xy() fixed
Implement Mesh.copy_vector_to_mesh() and use it from get_xy()
Use CooMatrix to assemble
Implement pysparse solver
Polish the numpy solver
Polish the printing a little bit
Rename assemble_jacobian() to assemble_matrix()

I fixed some build issues with FEMhub:

ondrej@crow:~/repos/femhub(master)$ git weekreport
Ondrej Certik (3):
Add gnutls dependency for Python
opencdk added
Fix libgpg_error to build in parallel

and I have some more patches to the build system in my "pu" branch at github:

* 44398d8 (github/pu) Use absolute paths in "femhub -i"
* 2b17bf0 Fix "femhub --devel-install" to normalize the paths
* 3b41261 Make "femhub --shell" stay in the current directory

I still need to test that femhub builds fine with those (it always takes quite some testing to make sure it builds properly).

Friday, June 11, 2010

week June 5 -- June 11

On Sunday I moved to Livermore.

On Monday I rebased my patches for Euler Equations, DG and FVM for hermes2d, sent for review. Unfortunately it took till Friday until they got reviewed, but they are now in.
I couldn't sleep, so at around midnight I turned on my computer and rewrote the build system for femhub, it took me about 1.5h. Then I could finally sleep well.

On Tuesday I had my new hire orientation. During it I wrote couple more patches for femhub.

On Wednesday I got my badge and spent the rest of the day with paperwork. They didn't manage to get my computer setup, so I studied a bit of Quantum Field Theory from a book that I found in our room and then spent the rest of the night figuring out the weak formulation for the radial Dirac equation. So far no luck, but at least I wrote it in many different forms in my hand written notes. Sometimes it's not bad to be cut off the internet and computers.

On Thursday I got my computer account setup and spent most of the day with paperwork.

On Friday I finally did some real work. Then we got to a pub, got home and drank the rest of my Budvars (Czechvar) and Plzeňs (Pilsner Urquell).

The FEMhub build system is really cool. It's written in Python and I totally got rid of the old Sage build system. Some features of the new one:

* dependencies
* automatically uses all your processors (unless told otherwise)
* simple Python script (414 lines) that handles everything, plus sage-env, sage-spkg and sage-make_relative scripts (the rest I simply deleted)
* allows you to install just some packages, for example "./femhub -i python" just installs python and it's dependencies
* allows you to unpack any package into the devel/ directory and then build it

I will not use it to develop hermes1d+schroedinger and dirac solvers over the summer, so it will likely get improved in the coming weeks. (I have to use it, because my computer is some old RHEL5, and I don't have a root access. With FEMhub, I have all the Python libraries plus cmake and similar stuff right there. It's really awesome.)

In total, I wrote 52 patches for FEMhub, 3 for hermes_common, 9 for hermes2d, 8 for hermes1d and 1 for sympy:

Ondrej Certik (52):
scipy and python upgraded
Remove the old buildsystem
New Python based buildsystem implemented
Install hermes2d by default
Compile in parallel
Let CmdException propagate
Handle dependencies
Fix the PYTHONPATH issue
Add a check that IPython is installed
Add Cython dependency to hermes2d
Add matplotlib to hermes2d deps
Keep track of installed packages
Add the -j option
Add the rest of the packages
Disable sphinx for now
Add a todo item
Disable mayavi for now
Add pysparse to fipy deps
Change the banner
Fix a typo
Remove old .hg files
setuptools added into fipy's deps
lab() implemented
Don't let other import errors to pass silently
Build bzip2 before Python
Simplify the makefile
Add the jinja2 package
Remove one forgotten " from a message
--shell and -s/--script options implemented
Fix cmake so that it builds if old cmake is present
expandvars() added to cmd()
Remove the rest of old buildsystem files
Move spd imports to femhub imports
Move download_packages into the femhub buildsystem
Remove a forgotten file from the old buildsystem
Create the standard directory if it doesn't exists
Polish the banner appearance
femhub-run: little refactoring
Use proper ipythonrc and matplotlibrc
Wrap lab(), add debugging statements
Don't import lab() in the ipythonrc
Fix the missing "-p" when creating the standard directory
Fix the problem with ambiguous names
cpu_count refactored
hermes1d added
-f/--force option added
--unpack added
--pack option implemented
--devel-install option implemented
Use MAKEFLAGS instead of MAKE env variable
Improve the FEMhub shell prompt
Print info when unpacking

Ondrej Certik (9):
Removing the old-code directory
hermes_common update
Reformat the documentation in the Geom class
Python wrappers updated
Regenerate the _hermes2d.cpp ScalarView updated
Element orientation exported
Sanity checks and docs
Add all shapefunctions to the space L2

Ondrej Certik (8):
spkg-install added
"make install" implemented
Make it build on the Mac
Allow to turn off examples
Use std::max(), fixed several warnings
hermes_common updated
Fix to work with FEMhub's SymPy
Fix the new line warning

Ondrej Certik (3):
Add numpy2c_double_inplace() to _hermes_common.pxd
Update the generated cpp file
Fix a small double -> int bug/warning

Ondrej Certik (1):
pyglet: fix string exceptions

Friday, June 4, 2010

week May 30 -- June 4

Over the weekend and Monday I went to Livermore, CA to rent a room to live. On Monday and Tuesday my uncle visited me from Prague so I showed him Virginia City and Lake Tahoe, that was lots of fun.

Then I tried to debug hermes1d and some matrix issues in there for couple hours, but failed so far.

I've helped Sameer to fix h5py to compile with FEMhub.

Yesterday I spent 12h setting up gitosis on our server and finally got it done, here is the web interface:

I had to patch the gitosis repository itself, here are my changes: (I've also sent them to Tommi Virtanen, the gitosis author, but I haven't heard back yet.)
In case you wanted to install it as well, I've posted instructions here.

I've figured out how to use msysgit with windows and use ssh keys to login to a linux box. It turns out it's not so trivial, see this issue.

I submitted the following patches to our projects at

ondrej@raven:~/repos/hermes1d(master)$ git weekreport
Ondrej Certik (3):
Reverting the change dfa8580
hermes_common updated
hermes_common updated

ondrej@raven:~/repos/hermes2d(master)$ git weekreport
Ondrej Certik (5):
Fix "make install" to work again
hermes_common updated
remove hermes_common/doc/Makefile from .gitignore
Fix the compilation warning

Btw, my "git weekreport" alias is defined as:

weekreport = shortlog --since=1.weeks --author=ondrej

Next week I am moving to Livermore, and my summer internship will get started.