Thursday, February 23, 2012
Text Size
Software Productivity

Productivity

Computer-Aided Engineering in Linux

Engineers are some of the heaviest number-crunchers around. If you are a grad student, post doc or undergrad, you usually get whatever is lying around as your work machine. Also, depending on how inflexible your local IT department is, you may be forced to use one of the commercial operating systems around these days. What are lowly students to do when they need to do heavy computational work? You may be interested in looking at CAELinux (Computer Assisted Engineering). This project provides a live CD that gives you all the open-source tools you might need for your engineering work. And, because it is a live CD, you can use it without touching the local drive of the machine you are using.

Like all live CDs, it has all the standard Linux desktop tools you should be familiar with, including Firefox for Web browsing, Evolution for e-mail, and OpenOffice.org for word processing, spreadsheets and presentations. Along with these applications, there are dozens of others to help with all your number-crunching work. The most recent versions are based on Ubuntu, so it should be a fairly comfortable environment for most people. Be aware, however, that you can't use the usual software update mechanism in Ubuntu. Many of the packages in CAELinux are compiled from source and optimized, so you don't want them being overwritten accidentally by any packages provided by Ubuntu.

Welcome to CAELinux

A really well written introduction to CAELinux is available right on the desktop, called "Getting Started". You should start here if this is your first step into the world of CAELinux.

Getting Started

Last month, I looked at OpenFOAM in this space. CAELinux includes a full install of OpenFOAM. It also includes another fluid dynamics program called SALOME. This program provides a full graphical interface that takes you from forming your problem, to modeling, to calculation and through to analyzing your results. This might be a good choice for those who are more comfortable with a GUI. A series of examples on the desktop are available that provide a walk-through of the program, showing each of the steps as you go through.

CAELinux Tutorials

As you can see, the tutorials walk through several common simulations, like modeling flow through a pipe. These can provide great starting points for many people.

If your work leans more toward data analysis, several popular packages are available. For all of you Matlab addicts, there is Scilab. Scilab provides the same types of functions in an environment familiar to Matlab users. There also is Maxima, which provides tools more from a mathematical background (for example, analyzing functions and doing calculus), as compared to Scilab's approach of working from a matrix background (such as looking at data analysis). Maxima has several front ends available. The default one in CAELinux is wxMaxima. If you are doing really heavy statistical analysis, there is R. The real power of R is the CRAN repository, and a fair amount is available out of the box. R also has several graphical front ends. CAELinux provides two: R Commander and RKWard. If you are doing work more along the lines of pure mathematical analysis, there also is Octave. The default GUI available within CAELinux is QtOctave. In all of these cases, text-based interfaces also are available, if you are an old-style computer user who prefers that kind of thing.

Several software packages exist for applications other than CFD or statistics. If you need to do finite element analysis, there's elmer. It provides both a text-based and GUI interface. There also is JavaFoil, available for doing analysis on airfoils and wings. If you are designing electrical circuits, two packages are available. Electric is a CAD program that helps you lay out a circuit. And, once it is all laid out, you can use PCB Designer to get it set up so you can etch a board to make it real.

This is all fine and good if you can use a standard toolset in your work. But, what if you need computing power for really cutting-edge research? CAELinux provides the entire GNU toolset. This means you have everything you need to go ahead and start developing your own code. All of the most common scientific and engineering libraries, like gsl and LAPACK, are available. If you are working on really large problems, MPI and openMP also are available. This way, you can develop a parallel programming solution if that is what your problem needs.

Once you have finished all your calculations, an important part of data analysis is graphical analysis. There is something visceral and instinctive about actually seeing your data represented. To this end, CAELinux provides several packages. If you simply want to plot your data, you can use programs like grace and LabPlot. If you want to do more complicated data analysis, you have programs like G3Data and OpenDX Data Explorer. These programs have lots of functionality that can be used to look at your data graphically. If you are doing CFD work, several programs for visualizing your meshes are available. So, you have your choice based on what features you need.

The last option to look at this month is using CAELinux in "the cloud". Cloud computing is one of those sexy terms that gets used a lot in marketing, but it sometimes doesn't really give you anything useful. In this case, there really is something substantial being offered. CAELinux now can be run as an application under Amazon Elastic Cloud Computing. You can now run, on demand, as many nodes as you like, each having eight cores and 64GB of RAM. For people who don't have the resources to run their own clusters, but need more than what a desktop can handle, this can be a very attractive choice. It definitely is worth looking into as a possible option. You can find more information about EC2 at http://aws.amazon.com/ec2, and the CAELinux Web site has a very good set of instructions to get you up and running.

As you can see, CAELinux provides a lot of power and functionality for doing computational science. Because it is a live CD, you can run it on essentially any 64-bit machine without touching the hard drive. But, you also have the option of installing it on the machine if you are allowed. Download an ISO and start playing with it to see just how much work you can do with it.

At Home With AV Linux

The AV Linux logo.

My studio computer collection includes two custom-built desktop machines and a Hewlett-Packard G60 laptop. As described in my previous article, the primary desktop box has been running an old but rock-steady 64 Studio 2.1 that has recently been replaced by a shiny new 64-bit Arch system. The secondary desktop machine and the laptop are both running the 32-bit version of Ubuntu 10.04. However, while I like and enjoy using Ubuntu I hardly require two identical installations of the same Linux distribution, so I decided to replace one of them with AV Linux.

What It Is

AV Linux is a complete Debian-based Linux distribution that includes optimized audio and video subsystems along with the expected wealth of system utilities and productivity software. A live version can be tested and used without disturbing your installed system, and an installer is provided if/when you decide to permanently add AV Linux to your boot menu.

Figure 1. AV Linux 5.0.1, at your service. (Full-size)

The AV Linux Web site tells us that the system is based on the stable "Squeeze" release from Debian Linux, the LXDE desktop and Openbox window manager, and the Remastersys utility. That last item is of particular interest - Remastersys can make a distributable copy of a personalized Debian or Ubuntu system, which is how AV Linux came into existence. At some point in 2007 Glen Macarthur recognized that his custom Debian-based audio/video production system could be useful to more users, so he spruced it up with some neat extras, pulled it all together with Remastersys, and voila, he created a new Debian-based media-optimized Linux distribution.

You can read the full story of the growth of AV Linux in its excellent manual. It's enough here to note that AV Linux has become a popular and recommended audio-centric Linux distribution. For good reasons, too, as we shall see.

Getting Started

I downloaded the AV Linux 5.0.1 ISO and burned it to a DVD. I tend to use disc-based installers, but my habitual way isn't always the best way to go, as I learned when I tested my first burned disc. On Day 1 it worked without incident, but on Day 2 it opened to a login dialog that should not have been there (this was a live session). Worse, for some reason the dialog rejected all my attempts at logging in. I checked Google, and sure enough I wasn't the first user to experience the problem. I thought I had verified the MD5 checksum for the ISO before I burned the disc, but I figured that starting over might give a clue to solving the problem. I retrieved a fresh copy of the ISO image, verified the checksum, and burned it to disc at a lower speed (8x). Alas, the same problem occurred, so I decided to try a Live USB stick instead. Still no joy, the problem persisted, until at last I realized that I needed to boot into AV Linux in its Failsafe mode. At once, the login problem was resolved and the system's performance was more responsive - and thus more enjoyable - thanks to the use of the USB key instead of the DVD. The DVD works fine, but use the USB method if you can.

By default AV Linux boots into its standard live mode, which should work fine for most users. However, if you experience the problem I've described try the Failsafe mode. I would have tried it sooner, but I mistook "failsafe" for "recovery", i.e. the single-user boot mode used for system maintenance and repair. In fact, the Failsafe mode simply starts a live session that bypasses certain boot-time options that can conflict with some hardware (such as mine, evidently).

After the system boots and passes its basic configuration you should see a screen similar to the display in Figure 1. You're now in the LXDE/Openbox environment, from which you can launch applications and perform further system modifications. You'll probably want to change certain system defaults, especially the settings for JACK. AV Linux has pre-configured JACK with rather conservative values that you'll need to change if you want the lowest possible latency from your hardware. You may also need to add yourself to certain groups to ensure that you have the correct permissions to access requested devices (e.g. a Webcam or an external drive).

Using AV Linux

In the lower left corner of the opening display you'll see a row of icons. The icon at far left summons the main menu for the AV Linux applications stack and system maintenance tools. As mentioned, you'll find all the major players in the Linux audio applications arena, from Ardour to ZynAddSubFX, along with a generous helping of video applications and utilities. System administration tools can be found in the main menu, or you can simply click on the AV Linux Control Panel (Figure 2), the icon just to the right of the main menu's icon. The Control Panel provides easy access to tools and utilities for system management, administration, and customization. Its amenities include an installer for ATI/nVidia binary video drivers and a very useful tool that scans and analyzes your system for its readiness for realtime performance.

Figure 2. The AV Linux Control Panel.

The other icons invoke the system's default file manager, an always-handy terminal window, the Iceweasel Web browser, the QJackCtl utility, and the WBar Dock, a neat "rolling" collection of program launchers. By default, the Dock includes launchers for the system's selected applications, but the user is free to add and delete items in the Dock.

The audio applications stack includes some unique selections. The stable Ardour2 is there, of course, but so is ArdourVST, a build of Ardour2 with support for Windows VST plugins (with some free VSTs to get you started). Demo versions of some commercial packages are included, making AV Linux a handy way to try Pianoteq or Renoise or the Loomer and linuxDSP plugins in an optimal system. Definitely a cool attraction.

Of course the stack includes the usual wonderful variety of free plugins in LADSPA, LV2, and native Linux VST formats, along with the variety of plugin-savvy hosts, e.g. Ardour, Rosegarden, Qtractor, Audacity, Guitarix, et cetera (see the manual for the complete list (PDF)). Csound5, Pd (any flavor), and SuperCollider3 are missing, but the first two are available from the default repos via Synaptic. I built SuperCollider 3.5 from its git sources, but only after searching for some Qt4 headers inexplicably missing from the Squeeze repos.

jEdit: a Text Editor and More

jEdit is a cross-platform text editor written in Java. The current stable version at time of this writing is 4.3.2, and it's available at http://jedit.org. Besides the cross-platform capabilities, jEdit offers other features, such as a sophisticated plugin system, syntax highlighting for 130 languages, a built-in macro language and extensive encoding support. I wrote this article using jEdit, and I demonstrate some of its features here, especially some of the plugins I have found useful.

Before I start, jEdit is a GUI text editor of some heft. It is not a replacement for using vi on the command line to edit a configuration file on a remote server. It does serve well in handling many files simultaneously with visual feedback and with the benefits of a GUI interface. To put it another way, I use vi or jEdit depending on the need.

Installation is fairly easy; just go to the download page and grab the installer jar. Be sure to check out the compatibility link if you have a non-Sun (Oracle) or Apple version of Java. From personal experience, I have not had success running jEdit on gcj. Assuming you have a compatible version of Java, use the following to install:


java -jar jedit4.3.2install.jar

This launches an installer program that guides you through the process. For the sake of reference, jEdit keeps its configuration files, on Linux anyway, in ~/.jedit/. I mention this because I keep that directory synced between my laptop and my desktop machines. As a result, I have a consistent working environment between the two.

At its heart, jEdit is a just a text editor, although it's a text editor with a lot of options. You can make these options global or apply them on a per-buffer basis. You can reach the options via the Utilities menu item. The global options stick between editing sessions, but the buffer options do not, unless you use the buffer-local method. This consists of embedding colon-separated hints to jEdit in the file. jEdit checks the first or last ten lines for these hints. As an example, to specify an indentation of 2, use spaces for tabs and "hard" wrap, the embedded hints would be:


:identSize=2:noTabs=True:wrap=hard: 

jEdit checks anywhere in those lines, so you can place the hints behind comment symbols.

Also note that jEdit supports mode-specific settings, where a mode is a file type, such as Python (*.py), C (*.c), HTML (*.html) and so on. The various modes come with default settings, but they can be overridden. One of the key benefits is that the mode system pulls in file-type-specific syntax highlighting. Other options are available for the editor's layout. As you can see in the screenshots for this article, I tend to run jEdit with two buffers open, split vertically and with line-numbering enabled. The ability to look at the beginning and end of file at the same time, especially source code, is invaluable.

You can use jEdit in a great number of ways. Watching me enter text, although it has its moments, is not terribly inspiring. So to keep things interesting, here I demonstrate some of the plugins I have found useful. Plugins are code that scratches an itch. The base jEdit program does a lot, but it does not cover the universe that is text editing, or other chores for that matter.

jEdit has a macro system (not covered in this article), so you can whip up your own solutions to problems or scope out the plugins available and not re-invent the wheel. So, before getting into the plugins themselves, here's an overlook at the plugin system itself. They can be found at http://plugins.jedit.org or via the Plugins item on the menu bar. Click on the Plugin Manager item and then the Install tab for a list of available plugins. Clicking on an item shows a description at the bottom of the page. Check the box of any plugin(s) you want to install, and then click Install. If the plugin has dependencies, they also will be installed.

So, where to start with the plugins? Let's go from less-involved to more-involved, beginning with one suggested to me by a member of the Bellingham Linux User Group: WhiteSpace. It does what it says—tracks whitespace. I have it set up to show trailing whitespace and, additionally, to eliminate any such whitespace when I save. I also have it show tabs and modify them according to my jEdit soft tab setting. This setting, when enabled, converts tabs into a defined number of spaces. WhiteSpace uses the setting to convert preexisting tabs into spaces or vice versa. All of the above helps when I work in Python code, keeping that pesky whitespace in order. This also is valuable when writing for Linux Journal, which requires that writers use spaces not tabs. See Figure 1 for WhiteSpace in action on a Python file. From the screenshot, you can see one way to set it up. The other way is to go to Plugins→Plugin Options→WhiteSpace. This is how most of the plugins work, although you will find there often are differences in options available between the two locations.

Figure 1. WhiteSpace Plugin Settings and at Work

Figure 1. WhiteSpace Plugin Settings and at Work

Another plugin I use quite often is JDiff. As the name implies, it shows the diff between files. Of course, you could use the command line to do the same thing. The benefit of the plugin is the graphical presentation it provides. Figure 2 shows the dual-diff mode using this article as the files. From here, you can create a diff output. You also can walk through the diffs and apply them from one side to another.

Figure 2. JDiff Plugin in Dual-Diff Mode

Figure 2. JDiff Plugin in Dual-Diff Mode

The JDiff plugin has a dockable component that allows you to drill down into the lines of the files for differences (Figure 3). In the dual-diff screenshot (Figure 2), you can see another plugin at work, VoxSpell. The underlining is the spell-checker at work. If you look at the file, you can see that plugin/plugins go from being underlined to not underlined. I right-clicked on the words and added them to the dictionary as acceptable, at least for the purposes of this article. Note that VoxSpell has a dependency on the Spell Check plugin. It also uses quite a bit of memory, so that may be an issue.

Figure 3. JDiff Dockable Showing Line Differences

Figure 3. JDiff Dockable Showing Line Differences

Next is a chicken-and-egg problem. I ran across a reference to the SQL plugin for jEdit. In the course of installing it, I found it had a dependency on the Project Viewer plugin, which meant I had to learn how to use Project Viewer in order to use the SQL plugin. It turns out that was a good thing. In fact, this article was written using Project Viewer. First, I will cover the SQL plugin and later expand on the Project Viewer plugin.

SQL allows you to work with SQL databases from within the editor. Setting things up to use the plugin is a two-step process. First, you need to do the general setup in the SQL options dialog. Go to the menu, then Plugins→Plugins Options→SQL. Go to the JDBC page and use the Add Element button to indicate the path(s) to the JDBC drivers you want to make known to the program. At the time of this writing, SQL can work with Oracle, MySQL, PostgreSQL, Firebird, DB2, Progress, MS SQL Server 2000, Sybase and Teradata, assuming you have the requisite JDBC drivers. This previous step "registers" the database so it can be used in the next step.

The next step is to configure a specific database (or maybe more than one) with a project. This is where Project Viewer comes in. You use it to create the project (more detail on that later). For now, I will use the project that is this article. From the project pane, right-click on the project name and select properties. This will lead to a series of dialogs that allow you to fill in the needed information (Figure 4). In this case, I am using the Pagila demo database for Postgres. From a jEdit buffer, you now have access to the database (Figure 5). There is quite a bit going on there, so let's take it a step at a time.

Figure 4. Adding SQL Server to a Project

Figure 4. Adding SQL Server to a Project

Figure 5. SQL Plugin Returning a Result Set

Figure 5. SQL Plugin Returning a Result Set

Just above the buffers is the SQL toolbar. First, above the left buffer is a Database: drop-down list with the previously configured database selected. To the right of that are four buttons: the first is Execute selection, the second is Execute buffer, the third is Load object, and the last is Repeat last query. To the right of the last button is the Preprocessors drop-down. For this example, I am using the Variable substitution preprocessor. This can be seen in the "actor_id > ?" expression in the SQL statement in the right buffer. (As a side note, notice the SQL syntax highlighting prompted by the use of the *.sql extension.) To continue, I have selected the statement I want to run and then clicked the Execute selection button. Because I have variable substitution in force, an input box was presented (not shown) for me to enter the value for actor_id, in this case 35. The result is presented in a separate window. From the result set, it is possible to save the data as CSV or tab format or as INSERT statements. You also can show/hide columns. Additionally, it's possible to run multiple statements at once (Figure 6). This is a somewhat contrived example, but it does show what's possible. The previous feature allows me to create database DDL files and run them from within the editor.

The last feature is SqlVFS (Sql Virtual File System). This allows you to browse the selected database as a filesystem. To get there, go to File→Open→Commands→Plugins→Show databases. Figure 7 shows what you get. Note that although Data says 0 bytes, double-clicking on it gives a result set from the table.

Figure 6. SQL Plugin Running Multiple Statements

Figure 6. SQL Plugin Running Multiple Statements

Figure 7. SqlVFS, Database as a Filesystem

Figure 7. SqlVFS, Database as a Filesystem

Project Viewer is a plugin to make handling a group of related files (a project) easier. For demonstration purposes, I'm using the files that make up this article. Project Viewer creates a docked button below the menu bar. Click it, and a drop-down appears with All Projects listed. Click this, and a window opens. Right-click on All Projects, and select Add project, and you get another window (Figure 8) to enter the required information. Click OK to create the project. Project Viewer then takes you to that project and puts up a prompt about importing files into the project. By default, it imports everything below the root directory.

Figure 8. Setting Up a Project Using Project Viewer

Figure 8. Setting Up a Project Using Project Viewer

At this point, the group of files is bound together as a project. The benefit is that Project Viewer keeps track of their state and allows you to return to that state at a later time. Note that it's possible to add other directories/files to the project later. Simply right-click on the project name, select Add files and navigate to the desired location(s). You can add new files from the existing directory in two ways: one is manual and the other automatic. The manual option is to right-click the project name and select Re-import files. The automatic option is to open the project name context menu, select Properties→Auto Reimport and enable it with a time parameter. Figure 9 shows the visual indicators as to the status of files, where underlining represents open files and color indicates type of files.

Figure 9. Files in Project Viewer

Figure 9. Files in Project Viewer

One really handy feature is the Compact View of a project. This is enabled in the General Options of the Project Viewer plugin options. It presents a flattened view of a directory structure. This article does not really have the directory depth to illustrate the benefit, so take a look at a screenshot from another project (Figure 10). Each line takes you directly to a directory. Also of note is the Working Files tab in the project window. This groups all your current open files together, which is handy in a large project.

Figure 10. Project Viewer Compact View

Figure 10. Project Viewer Compact View

Some other features include archiving the project files in a JAR file and searching in the project or project subdirectory files for a string. The ability to consolidate all of the files related to a project in a single interface is something I've come to appreciate even more as time passes. Walking through a Project Viewer directory tree renaming/moving/deleting files while looking at the actual files is priceless.

What I have presented above barely scratches the surface of what is possible with jEdit. It has a macro facility that I have not even started to explore. The most important part of jEdit, to me, is that it lets me get work done without getting in my way. Furthermore, it makes that work easier, and I hope you find it useful also.

More Articles...

Page 1 of 2

<< Start < Prev 1 2 Next > End >>

AVG Anti-Virus Pro Rolls Heavy Artillery Onto Deserted Battlefield

AVG Anti-Virus Pro, an app from AVG Mobilation, is available for US$4.99 (premium upgrade version) at the Android Market. I've...

Mint With Cinnamon: A New Sweet Spot for Desktop Linux?

Well CES is nearing its conclusion for another year, winding down an event that may well have brought Linux more mainstream...

Oracle Makes Bold, Risky Move With Big Data Appliance Launch

Oracle (Nasdaq: ORCL) has released its Big Data Appliance, which it announced last year at Oracle OpenWorld. With no release...

Updating the ROM in Your Mobile Device

Remember this: The phone or tablet you purchased is yours. It does not belong to the carrier that you bought it from despite...

Google's Schmidt Does the Android Definition Boogie

As Android smartphones sell like hot cakes -- 3.7 million were reportedly activated on Christmas Eve and Christmas Day --...

Open Source: Not Just for Tech Anymore

Amid the many predictions for 2012 regarding Linux and open source software, including my own forecast of Linux domination,...
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7