User:WillWare/NanorexPage

From Wikipedia, the free encyclopedia

This page was from my happy days a Nanorex employee.

It's frequently handy to refer to the Mediawiki help contents. I have some ideas for future enhancements and features and things for Alpha 8.

GPL intricacies[edit]

Legal background

  • Reciprocity and the GPL
  • When will my work fall under copyleft obligations under the GPL?
  • What is a derivative work?
  • Text of the GPL
    • These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
    • This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.

GNU Classpath distributes code under the terms of the GPL but with the following clarification and GPL linking exception:

  • Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination.
  • As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obliged to do so. If you do not wish to do so, delete this exception statement from your version.

So it looks like the copyright holder is allowed to reduce the virality of the GPL terms, if he wants. I don't know whether one needs legal counsel to do this right.

Graphics C code[edit]

Learn all of OpenGL and study Brad's code. Order the OpenGL Red Book and Blue Book? The text is available online.

My code should follow the OpenGL precedent for nice clean APIs.

Build a library of C/Python OpenGL drawing objects for atoms, spheres, cylinders, etc. Be able to handle triangle lists. Pyrex could be used for this, or it could be done as a vanilla C extension.

Brad used arrays of drawing parameters. Because of vertex buffer objects, it makes sense to draw all of one shape, then all of another, etc, setting up a pipeline.

Sort by depth

  • You can't do transparency in the general case unless you've already sorted by depth.
  • The level of detail should be based on the visible size of the triangles in pixels, which depends primarily on depth. Use this to simplify the drawing of spheres, cylinders, etc that are far away.

Building OpenBabel on Cygwin[edit]

It looks like the solution to bug 2190 is to build OpenBabel on Cygwin with static libraries, so that it doesn't try to require cygwin1.dll. I'll put together some notes about what's involved in getting it to build. Remember that before you run the configure script, you need to take Makefile.am, Makefile.in, and mmpformat.cpp from the cad/src/experimental/openbabel/src/formats directory and put them in OpenBabel's src/formats directory.

For the moment, I'm just struggling with getting it to build. I'd forgotten some problems. In obutil.h, you need to eliminate references to gettimeofday(). In src/, there is apparently a problem with building bondtyper.cpp. That might go away if I try configure without "--disabled-shared", so I'll try that first.

Things I want to work on[edit]

  • Animations of simulations, for Google Video and putting on DVDs
  • User:Will/Things I would like to do
    • Librarification and scripting, JNI/Swig for the simulator
      • As long as it doesn't violate the Qt license, a user should be able to use complex scripting where simple GUI commands aren't sufficiently expressive, e.g. which atoms should be shown in detail
      • EricM's CNC jig could be an example
    • Jigs and jig-related stuff
      • Constructive solid geometry library
      • Mechanical jigs: point mass, rod, spring, damper, rectangular solid, CSG solid
      • Casings - requires CSG description of enclosed volume swept by moving parts during an operation cycle
    • Electrostatics
    • Schafmeister building blocks and others, start putting them in the partlib, later think about special UI support
  • Documentation
    • Fundamental classes in NE-1 - put together a clear description of all these
      • Nodes
      • Assemblies
      • Molecules - are these the same as chunks? I never remember...
        Chunks in our code used to be called molecules (and are still represented by class molecule), but never corresponded to the chemistry term "molecule". -- Bruce 01:55, 20 Jul 2006 (CDT)
      • Atoms
      • Bonds
    • Recipes
      • Example: Find all the sp3 carbons in a structure, and do something to them
    • Python idioms
      • Use dictionaries instead of lists, they're faster - any cost to using them? memory usage?
      • "is" is faster than "=="

Stuff[edit]

A brilliant video demonstrating modes, the solutions to the wave equation, in a square resonator.

Combinatorial optimization and automated design[edit]

Combinatorial optimization (or global optimization) comes up in a huge number of different contexts, many pertaining to design of complex systems and devices. You have a function f: SR and you want to find the global maximum or global minimum. S is the search space, the space of possible parameters. The parameters are typically a collection of reals and integers so that SZM × RN. (Booleans can be considered a special case of integers.)

When searching for an optimal design, we consider each possible design to be a point in the search space and we seek the design with the highest fitness. We then usually refer to S as the design space rather than the search space, but we are still searching it in the same manner.

In the case of energy minimization, the function gives potential energy of a structure in terms of the spatial coordinates of the atoms, which are all reals. We do a coarse minimize using steepest descent until both the cutover RMS and the cutover maximum force criteria have been satisfied, and then do a finer minimize with Polak-Ribiere conjugate gradient until both the end RMS and the end maximum force criteria have been satisfied.

Methods like gradient descent and conjugate gradient work fine for the real inputs to the fitness function. What do we do for the integers? Sometimes we can exploit regularities of a metric function, with algorithms such as simulated annealing or genetic algorithms, if we have some idea what those regularities are.

Usually in a combinatorial optimization problem, the majority of the expense is in evaluating f, and algorithms almost always seek to find optima with the smallest possible number of function evaluations.

An example in the world of design is prototyping, where the construction of a prototype is a fitness test of the design parameters for that prototype. When we build a prototype, we usually study it as carefully as possible to learn as much as we can, and where possible, we tweak design parameters to get a sense of the fitness gradient around that point in the design space. I have been going through this process while working on a prototype of a hoverboard in recent days.

Given a sufficiently accurate simulation, the fitness of a design can often be evaluated on a computer. This is safer and cheaper than testing physical prototypes, and often faster as well. NASA has been using genetic algorithms to design evolved antennas.

Other stuff one can do with combinatorial optimization: FPGA and PCB place and route, designing car engines, scheduling and resource allocation, John Koza's invention machine

Nanotechnological artifacts are likely to quickly become more complex than any previous human artifact. Simulation and combinatorial optimization will be important design techniques. Human tweaking of individual design parameters will be far too slow to make significant progress.

A distinct engineering discipline[edit]

I think this collection of methods and algorithms may come to be recognized as a distinct engineering discipline, with degree programs for optimization engineers, who will work on complex design and in many other problem domains. There are various areas that will merit the attention of designers using these techniques.

  • The choice of a fitness function
  • The choice of optimization algorithm, and the choice of any adjustable parameters in the algorithm
  • An ability to recognize useful properties of the design space
  • The speed and accuracy of the simulator, which affects the cost of a fitness function evaluation - this is really a separate specialty, but one with which an optimization engineer would need to be familiar

Sometimes the design space is partitionable, with S = S1 × S2, and we can search S1 and S2 separately at considerably reduced computational cost. If they are weakly coupled, we may need to alternate search steps between them but the arrangement is still advantageous because of the reduction in the number of dimensions. A nice example of partitioning (which has nothing to do with design) is the Born-Oppenheimer approximation.

Nanotech projects for hobbyists and students?[edit]

I've heard that high school groups have built scanning tunneling microscopes. It would be nice to collect pointers to projects like that, and maybe re-host some of the instructions for such projects.

Maybe there are other interesting high-school-level experiments.

alt.sources postings[edit]

Sometimes I put helpful little programming tricks on the alt.sources newsgroup.

Linux stuff[edit]

Here are a bunch of things that are helpful when bringing up a new Linux box.

My .bashrc[edit]

if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

alias hi="history | less"
alias cad="cd /home/wware/polosims/cad/src"
alias sim="cd /home/wware/polosims/sim/src"
alias dist="cd /home/wware/polosims/Distribution"

export CVS_RSH=ssh
export CVSROOT=wware_at_cvs2.cvsdude.com:/cvs/polosims  # _at_ -> @

unalias rm
unalias ls

ulimit -c 500000

My .emacs[edit]

This is stuff I add to the system's default .emacs file.

(setq set-fill-column 78)

(setq inferior-lisp-program "guile")

(setq sentence-end-double-space nil)

(setq make-backup-files nil)

(defun f8-function ()
  (list-buffers)
  (delete-window))

(setq default-tab-width 8)
(setq tab-width 8)

(setq c-basic-offset 4)

(global-set-key "\C-l" 'start-kbd-macro)
(global-set-key "\C-o" 'end-kbd-macro)
(global-set-key "\C-p" 'call-last-kbd-macro)
(global-set-key "\C-n" 'goto-line)
(global-set-key "\C-b" 'switch-to-buffer)
(global-set-key "\C-xp" 'blink-matching-open)
;; (global-set-key "\C-u" 'scroll-down)
(global-set-key [f35] 'scroll-up)
(global-set-key [f29] 'scroll-down)
; (global-set-key "f8" 'f8-function)

(setq line-number-mode t)

(add-hook 'text-mode-hook
  '(lambda () (auto-fill-mode 1)))

(setq-default fill-column 70)

;; C color coding
(defun my-c-mode-hook ()
  (turn-on-font-lock)
  (setq c-basic-offset 8)
  (c-set-offset 'substatement-open 0) ; this is the one you care about
  (c-set-offset 'statement-case-open 0)
  (c-set-offset 'case-label '+)
  (setq tab-width 8)
  (setq indent-tabs-mode t)
  (message "my-c-mode-hook function executed"))
(add-hook 'c-mode-hook 'turn-on-font-lock)
(setq line-number-mode 1)

(defun j4 ()
  (setq c-basic-offset 4))

(defun my-java-mode-hook ()
  (setq c-basic-offset 8)
  (c-set-offset 'substatement-open 0) ; this is the one you care about
  (c-set-offset 'statement-case-open 0)
  (c-set-offset 'case-label '+)
  (setq tab-width 8)
  (setq indent-tabs-mode t)
  (message "my-java-mode-hook function executed"))

(add-hook 'java-mode-hook 'my-java-mode-hook)

(setq auto-mode-alist
       (cons '("\\.ui$" . sgml-mode) auto-mode-alist))

;(load-file "/home/wware/emacs/lisp/python-mode.el")
;(autoload 'python-mode "python-mode" "" t)
;(setq auto-mode-alist
;      (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq auto-mode-alist
       (cons '("\\.pyx$" . python-mode) auto-mode-alist))

(autoload 'cscope-bind-keys "cscope" nil t)


(defun linux-c-mode ()
  "C mode with adjusted defaults for use with the Linux kernel."
  (interactive)
  (c-mode)
  (setq c-indent-level 8)
  (setq c-brace-imaginary-offset 0)
  (setq c-brace-offset -8)
  (setq c-argdecl-indent 8)
  (setq c-label-offset -8)
  (setq c-continued-statement-offset 8)
  (setq indent-tabs-mode nil)
  (setq tab-width 8))

;;;
;;; Get rid of those nasty ^M characters at the end of tip window lines
;;;
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m t)
(add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt)

;;;
;;; Use this when it looks like you might have an unclosed comment or string.
;;;
(global-set-key '[f9] 'font-lock-fontify-buffer)
(global-set-key '[S-f9]
                (lambda ()
                  (interactive)
                  (progn
                    (font-lock-mode nil)
                    (if (and
                         (numberp font-lock-maximum-decoration)
                         (< font-lock-maximum-decoration 9))
                        (set-variable 'font-lock-maximum-decoration
                                      (+ font-lock-maximum-decoration 1))
                      (set-variable 'font-lock-maximum-decoration 1))
                    (font-lock-fontify-buffer)
                    (font-lock-mode t))))

;; Clean up indentation, and remove any blank space at the end of the line.
;; Go on to the next line. Use ctrl-U to do a bunch of lines.
(global-set-key
 '[S-f10]
 (lambda ()
   (interactive)
   (progn
     (beginning-of-line)
     (c-indent-command)
     (end-of-line)
     (delete-horizontal-space)
     (beginning-of-line)
     (next-line 1))))

;;;
;;; Need easy access to search & replace.  This one is good because it matches
;;; regular expressions without getting in the way.  On the "to-string" side
;;; of things, use '\&' to match the whole regexp and \{digit} to match the
;;; {digit}'th '\(...\)' in the regexp.
;;;
(global-set-key '[f3] 'replace-regexp)
(global-set-key '[S-f3] 'query-replace)
(global-set-key '[C-f3] 'query-replace-regexp)

(global-set-key
 '[f4]
 (lambda ()
   (interactive)
   (progn
     (mark-whole-buffer)
     (tabify (point-min) (point-max)))))

(put 'upcase-region 'disabled nil)

(put 'downcase-region 'disabled nil)

;; (setq inferior-lisp-program "/usr/local/bin/clisp")
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(case-fold-search t)
 '(current-language-environment "Latin-9")
 '(default-input-method "latin-9-prefix")
 '(global-font-lock-mode t nil (font-lock))
 '(show-paren-mode t nil (paren))
 '(transient-mark-mode t))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )

ssh-agent[edit]

ssh-agent is a really handy authentication agent for SSH because you don't have to keep typing your password every time you do a SSH or CVS operation. Here are some documents that look potentially useful.

Of course, what we really care about is using ssh-agent as it applies to cvsdude.org.

Wireless on Linux[edit]

Fedora Core[edit]

Getting wireless working on Fedora Core is a little tricky, requiring a package called ndiswrapper plus some files from the Windows wireless driver. Typically these files will have names ending with ".inf" and ".sys", and the rest of the filename will often be the same.

DEVICE=wlan0
TYPE=Wireless
MODE=Managed
ESSID=linksys
KEY=02468ABCDE  # ten hexadecimal digits
BOOTPROTO=dhcp
ONBOOT=yes
USERCTL=yes
PEERDNS=no

Mandrake 10.1, Mandrake Powerpack 2006[edit]

Mandrake included the build for ndiswrapper so you don't need to rebuild it yourself. Very nice. Become root, run "drakconf", select "Network & Internet", select "New connection", select "Wireless connection". At some point you will be asked for "bcmwl5.inf".

Random useful stuff, maybe[edit]

Where does the ".bashrc" file go with Cygwin/MinGW?

Setting up a Mac as an ssh server (look for the heading "don't forget to turn it on")

A bit more detail: "SystemPreferences" is under the small light blue apple in the far upper left corner. "Sharing" is in the "Internet & Network" division. From there, switch on "Remote Login".

Stuff I've worked on[edit]

The farther back in my memory I have to dig, the harder it will be. Let's try to keep records. Maybe recording what I've done recently will be more useful than using the wiki to try to figure out what I should be doing in the near future.

  • Sept, Oct 06 - Worked on the animation of the small bearing. Worked on the transition to Qt 4.
  • 20 July 06 - Worked on Alpha 8, lots of bug fixes. Worked on DNA/nanotube/graphene generators, sponsor buttons, Pyrex atoms, plug-in architecture, plotting energy during dynamics runs, unfinished work on nanotube endcaps. Recent preliminary work on OpenGL optimizations associated with Pyrex atoms, and a bitmap font.
  • 3 Apr 06 - Alpha 7 bugs are substantially fixed, a little non-urgent work left on bug 1783. I've given some thought to pyrex atoms and bonds over the weekend which I want to follow up on. Also some ideas for mixed-mode simulation, where we simultaneously do molecular dynamics and rigid-body dynamics.
  • 31 Mar 06 - More A7 bug fixes. Some work on the Mac release package, aquaterm library was being put in a wierd place. Resolved issues with a lot of the jig tests failing on Windows; some still fail.
  • 23 Mar 06 - Ongoing bug fixes for Alpha 7 release.
  • 14,15 Mar 06 - Went to Michigan to help out with final push for Alpha 7 release. Mostly bug-fixing stuff.
  • 1 Mar 06 - Committed code for Pyrex atoms, atom sets, diff factories and diff objects into the head. It didn't seem to break anything.
  • 22 Feb 06 - More Pyrex atoms and bonds.
  • 21 Feb 06 - Demoing nE-1 at the University of Florida Engineering Fair, with the Gator Nanotechnology Club
  • 17 Feb 06 - Pyrex atoms and bonds and atom sets. Help Ninad get up to speed with Mac release builds.
  • 9-13 Feb 06 - Bug fixes, jig tests. Fixed a few remaining rotary motor bugs for zero speeds and teeny speeds.
  • 6-8 Feb 06 - Helped Brad G with Pyrex/OpenGL stuff, some annoyances with Apple's Unix implementation. Fixed bugs. Gave Eric D a couple of Mac release packages so he could keep up with Mark's UI work.
  • 3 Feb 06 - Good progress on FC4 build, FC5 may be more challenging. Random bug fixes.
  • 30 Jan-2 Feb 06 - More bug fixing, making sure pyrex extensions work in release builds, release build script maintenance, thought more about supporting Linux distributions. Worked on Fedora Core platform (bug 1058, others) but didn't get far.
    • Alas the Nanorex wiki is gone. The fix for bug 1058 was to add the keyword "volatile" to the definition of "ret_val" in the dlamc3_ function in numpy/linalg/dlamch.c. This was needed because the automatic translation from Fortran done by f2c didn't quite understand the role of "volatile" in C.
  • 1 Feb 06 - last? spasm of rotary motor work: found a bug in earlier damper code, reinstated flywheel and springs with correct damping
  • 27-29 Jan 06 - Fixed assorted bugs.
  • 26 Jan 06 - More work on angle bend parameters.
  • 25 Jan 06 - Wrote a script to help Damian process GAMESS data faster and with less pain. A little work on bugs, work on angle bend parameters.
  • 23-24 Jan 06 - Lots of work on the Pyrex OpenGL extension, I'm guessing it will be available for Alpha 7, which will be a quite cool graphics speed-up. Unit tests now run on all three platforms. Learned a little more about PyQt and OpenGL in the process. Preliminary work on finite element models for elasticity and viscosity of rectangular solids.
  • 20 Jan 06 - Try to resolve Mac build issue for Pyrex OpenGL. On the rotary motor, think about some kind of mechanism for keeping the atoms at about the same radius from the axis.
  • 19 Jan 06 - Got Pyrex OpenGL working on Windows, still not working on the Mac. Tried a new motor axis idea involving roughly coplanar atoms and lots of linear algebra, branch wware_nearlyCoplanar_20060119 in sim/src.
  • 18 Jan 06 - Worked on Pyrex extension for Brad Grantham's OpenGL acceleration of sphere and cylinder drawing.
  • 17 Jan 06 - Check in the new simpler rotary motor, which fixed bugs 1306, 1327, 1328, 1336. Also fixed bug 1338.
  • 14-16 Jan 06 - did a bunch of rotary motor simulation and debug, realized the motor's oscillations were due to two rotational masses connected by a weak spring, wrote a rotary motor with no spring and no separate flywheel
  • 13 Jan 06 - simulator bug fixes, work on sim/src/tests.py, start running more rotary motor simulations
  • 12 Jan 06 - discovered that rotary motor is still unstable in long simulation runs, did some simulator bug fixes, some work on Interrupted versus Python exceptions
  • 11 Jan 06 - lots of work on simhelp.c for better exception handling in Python callbacks, then more rotary motor and speed controller work, finally understood Verlet integration
  • 6-10 Jan 06 - more rotary motor, raising Python exceptions in Pyrex extensions, making the simulator scriptable#Long-term scripting goals, also tinkering with making jigs a lot more modular
  • 5-6 Jan 06 - rotary motor vibes, hacking OpenGL with Pyrex
  • 1-4 Jan 06 - various work on Pyrex sim interface for real-time movies, and Pyrex testing and unit tests
  • 29 Dec 05-3 Jan 06 - building Pyrex on Windows with GCC
  • December 05 - building release packages, more measurement jigs, more sim lookup tables, rotary motor vibes, reversibility and energy conservation, prepping wiki for alpha users
  • November 05 - nanotube generator dialog, more measurement jigs, sim lookup tables and piecewise polynomial approximation
  • October 05 - getting up to speed, starting to populate this wiki, Foresight conference, measurement jigs, vibrational mode analysis
  • September 05 - met with Josh and Bruce in Calif, discussed making the simulator scriptable and other architecture stuff