Running CalculiX on Amazon EC2 cloud service

Many engineering problems require powerful PC to run FEA. It is not true for regular CAD work (for example in Solidworks) - having average (not very expensive computer) and general computer knowledge you still able to work with comfort (if you do not like to run many programs at once, because actually many browsers and messengers are eating more memory than powerful CAD).
But FEA software require usually require powerful machines to be able to solve complex nonlinear problems with contact, pretensioned bolts and etc.
At home I am using relatively old laptop with 4 cores and 8 GB of memory under Ubuntu 14 and solving of some problems is not so easy, if they can't be simplified. In this case there is relatively cheap solution, that is only need some money + Internet connection (not necessarily very fast).
You may rent remote computer on Amazon, Google (not sure, but probably Microsoft) and enjoy the power for relatively cheap cost.
Here is the description about running Caelinux, using cloud service (for European users). But I want to describe simple way to run just CalculiX on regular Ubuntu remotely.  
At first get registration at here https://aws.amazon.com/ 
setup your login, password and payment options.
Then go to https://aws.amazon.com/ec2/ 
and get started. I don't want to describe it in all details, read the information on website. But I can tell just two things. You should create and save security .pem file and select VM instance for your first test. At the beginning it can be weak and slow machine with minimum of memory, that is available for free (for some amount of hours). It is more than enough for test. Also select Ubuntu for OS.
My description below is about running remote Ubuntu from my home Ubuntu but basically you can do it from Windows or any other OS (using PuTTY or web-browser). 

1) At first, you have to connect to remote Ubuntu. I am doing it from terminal emulator:

sudo ssh -i /path/to/saved/file.pem ubuntu@ecX-XX-XX-XX-XXX.us-east-2.compute.amazonaws.com

where "ecX-XX-XX-XX-XXX.us-east-2.compute.amazonaws.com" can be copy-pased from EC2 management web-page  - Public DNS (IPv4).















Enter your local ubuntu password (after "sudo") and type yes, when it is asking "Are you sure you want to continue connecting?". Now your terminal emulator is serving for remote VM Ubuntu linux. Saying first, it is completely pure linux, just as command line and it doesn't have even one user (you're root). Here what you can do - is to create user, and then install Ubuntu GUI and special remote desktop software like x2go or No-Machine. Make search about that, like: "amazon GUI linux"
This feature (remote linux) is usually for professional computer specialists, servers, web-applications and things like that, and they need nothing except command line. Using remote machine for FEA and numerical calculation is not so typical. 
But we won't use GUI because it is actually not needed. All you need is to get some practice for 2-3 linux commands, described below.

 2) Let's install CCX (solver) on remote VM. Statically linked version, provided with CalculiX launcer doesn't require installation. We will just copy it with card like: 

wget "https://drive.google.com/uc?export=download&id=0B1dVWvbd4cYgOFBjUS1vSzN6M0k" -O ccx

wget means download from web, and in this case I am using modified link for my GoogleDrive (you can also use it, or share ccx executable from /bin  folder on your own drive. The sharing link should be modified with prefix:

https://drive.google.com/uc?export=download&id=

Otherwise you will download html page from google. Also this trouble may happen with large files, so learn how to use .tar.gz archive (typical type for linux) and use wget for archive.
If you have access to your own ftp - use it instead of google drive. You're free to search and read about "wget" in the internet (this is just linux shell command)

3) Get the test sample, for example:

wget "https://drive.google.com/uc?export=download&id=0B1dVWvbd4cYgXzBkcS1MdU9JZ2s" -O test.inp

This is the testing text file test.inp
Allow executing of CCX

chmod +x ccx

and run test.

./ccx test

You should be able to see typical ccx output and "Job is Finished"

4)  the whole reason why we use cloud service - is powerful computer with many cores. You should create environment variable for ubuntu, as it is described in the ReadMe(ubuntu).pdf in CalculiX Launcher. This is also described in CCX help files. Type:

touch ~/.pam_environment

and then

nano ~/.pam_environment

(nano is the text editor for Ubuntu)
Remember, that you're root on VM and "sudo" is not needed. 
Create two lines in the text file: 

OMP_NUM_THREADS=64
export OMP_NUM_THREADS


64 is maximal number of cores, available on remote PC (for money).
Then do:
ctrl+O
ctrl+X

(save and exit from nano)
After restart of remote VM you should be able to see how many cores you have in calculation (CCX output).
5) For real problems the inp file can be uploaded on google drive as tar.gz arcive, you may get it from there, for example:


wget "https://drive.google.com/uc?export=download&confirm&id=BUNCHOFNUMBERSANDLETTERS" -O static5.tar.gz
Untar it on VM:

tar -zxvf static5.tar.gz

After calculation is done and it was successful  you can make archive from frd (results) file before you will pull it back on your home machine for post-processing.

tar -zcvf static5.tar.gz static5.frd  


6) Final step - is getting archive file with results from VM to home. There are bunch of ways to do it, but I am using command like:

sudo scp -i /path/to/saved/file.pem ubuntu@ecX-XX-XX-XX-XXX.us-east-2.compute.amazonaws.com:static5.tar.gz /home/me/Desktop 

This card is running in separate terminal emulator on my local machine, but also it can be used on VM instance. Read more about secure copy, linux shell, for example here: http://www.hypexr.org/linux_scp_help.php

7) Few general notes:
- you can prepare all linux shell commands in separate text file, to copy-paste them then without typing.
- ecX-XX-XX-XX-XXX.us-east-2.compute.amazonaws.com is variable for each session of VM instance. Get it from amazon web-page.
-some additional linux shell commands, like "file", "nano" can be useful for blind work on remote VM. This information can be found everywhere in web. It is not something special about amazon or CalculiX.





Terminal Emulator For CalculiX Launcher

The idea of CalculiX Launcher for Linux is to provide software, that is maximally portable (with minimal dependence to other libraries).
But it is not always possible because the size of binary is growing up when you merge it with libs.
There is a simple way to get know, what kind of binary file you have.
Just open console in the folder (or cd ... to it) and apply 'file' command to the binary.

file binary

For example, CCX is statically linked (requires only linux kernel to work)


















CGX, GMSH and Launcher itself, need some basic libraries (like GTK-2 for GUI).
Python 2.7 is provided as statically linked  (for predictable work of some py mesh converters).

Also you need terminal emulator to be able to run CCX and CGX. This simple software can be different for known linux distributions but most elementary terminal emulator, called xterm, can be used in this case.
In ubuntu you can install it as usual:

sudo apt-get update
sudo apt-get install xterm
 
In worst case, there is a way to obtain statically linked xterm (about 5mb)

ftp://iraf.noao.edu/pub/fitz/xgterm.STATIC
ftp://iraf.noao.edu/pub/fitz/ximtool.STATIC

http://iraf.net/forum/viewtopic.php?showtopic=1468252

Make them executable and move to /usr/local/bin with the commands

% chmod 755 /path/xgterm.STATIC
% sudo mv /path//xgterm.STATIC /usr/local/bin/xterm


or any way you know, to do this standard action.
Here is link for yandex-drive and google-drive to get this executable (32bit kernel).


Gentry Crane - FEA



Note: Buckling ratio k=5.4 >1 what doesn't mean that safety margin for buckling is 5.4
This is true only for very flexible structures (Euler's buckling is real). In general case you should use code requirements to estimate real safety ratio. Euler's results can be used for estimation of effective length of column Lef. Just use the formula:

K*Static_Axial_Force = 3.14^2 *E*J/Lef^2

Lef = 3.14*(E*J/(K*abs(static_axial_force)))^0.5

where all parameters are taken for Euler's formula for elastic buckling (E - Young's Modulus, J - bending moment of inertia, etc).
K and Static_Axial_Force obtained for the same (lower) mode


 Code requirements take into account plastic properties of material, real safety margin will be lower than 5.4


Limit State in CalculiX (LRFD calculation)



 

This is quick example for limit state, calculated with plastic card
This problem has simple analytical solution for limit moment

Mpl = Yield Stress *  Plastic section modulus 














Using CalculiX you can obtain numerical solution (the limit state when deflection is growing without load increment)














Get files and spreadsheet (LibreOffice with macros) at here
https://yadi.sk/d/6mMnQkKD34nQAj

At some cases composite shell with many integration points should be used for limit state calculation.
















See the example at here.

How To Analyse Stress State In Practical Applications

This article is explanation of videos, stored at here.
When students start to learn strength of materials he is getting
information like :

Max. equivalent stress <= [Limit stress]

This is very simplified approach, and maybe enough to know for the overall development, but not enough to solve practical problems.

Basically there are many different types of limit states and the above formula is not a criteria of failure, it is just general formula for start of yielding (when stress at some point comes to yield surface.

For example, stress can be lower than yield strength to get fatigue failure after many cycles and it can be easily much more than yield strength to resist sufficient  amount of cycles for your problem.

In practical applications people use code requirements. The history of technical codes has more than 100 years with huge experience of service under the different loads and conditions.

Let's take ASME BTH-1–2005 "Design of Below-the-hook lifting devices"
It uses allowable stress method, but it says:

The allowable stresses and stress
ranges defined in paras. <...>, and <...> are to be com-
pared to average or nominal calculated stresses due to
the loads defined in para. <...>. It is not intended that
highly localized peak stresses that may be determined
by computer-aided methods of analysis, and which may
be blunted by confined yielding, must be less than the
specified allowable stresses.


Actually this code (as many other national codes) uses common formulas  of beam theory, like P/A+M/Sx
what means that it operates with averaged fiber stress, not with peak values.

Let's solve simple example to show the difference between fiber stress and peak stress ( https://yadi.sk/d/paoQtcq133zorf )

I-beam (b=h=6'', tw=tf=0.5''), fixed at one end and loaded with concentrated moment M=250000 lb*inch at other end.

Moment of inertia: Ix=2*6*0.5^3/12+2*6*0.5*2.75^2+0.5*5^3/12=50.7 inch^4
Section modulus: Sx=50.7/(6/2)=16.9 inch^3
Fiber bending stress  =M/Sx=250000/16.9=14800 psi
















Fig.1 - I-beam with hole













Fig.2  - Section properties
















Fig 3 - Distribution of fiber stress (von Mises)
















Fig 4- Peak stress at stress concentration point


Let's explain all values:
1) Fiber stress is subject of technical codes, based on allowable stress design
It should be less than yield strength in most of application (the exception is LRFD - load resistance factor design, where M/Sx>yield stress
LRFD  is not applicable to structures with cyclic load
Allowable stress can be less, than yield stress (for example for elevators it is equal to 14 ksi for normal load and 27 ksi for emergency stop) 
In CalculiX you can investigate fiber stress using 'max' card in CGX

2) Peak stress at stress concentration point can be much more than yield stress in many applications. It is subject for fatigue analysis, based on total deformations (elastic+plastic)

3) Situation when peak stress = yield stress don't make sense practically. It doesn't provide protection against fatigue because yield stress > fatigue threshold. Peak stress can't be used for allowable stress design, because usually it gives huge unnecessarily  safety margin for most of practical applications and it doesn't provide complete safety in general. It is mostly some limit that make sense in theory (start of yielding at some point)
Peak stress is infinite in many FEA models due to singularity (solution with plastic card is not helpful in this case, because stress and strain stay infinite).
It is subject of Fracture mechanics and it uses other values, not stress or strains but sort of averaged stress)  
In this case  hydraulic  analogy can be useful for understanding. it doesn't matter what is peak maximum of velocity, but flow rate is result of integration over the stream).

It is what ASME BTH-1–2005 "Design of Below-the-hook lifting devices" says about that

"While the use of such methods is not prohibited, modeling of the device and interpretation of the results demands suitable expertise to assure the
requirements of this standard are met without creating unnecessarily conservative limits for static strength and fatigue life."


Many commercial programs, like ANSYS, Solidworks Simulation,  and etc, use this approach when calculate "Safety Factor" but it is not perfect and doesn't provide accuracy (as people think when they buy expensive software)
The great benefit of using FEA, is getting accurate numerical solution of stress distribution. Elasticity Theory proves the theorem of Existence and Uniqueness of Solution, that means all (properly tested) FEA programs should give the same results (which depend on boundary conditions, applied by user, under the user's responsibility). But knowing correct stress distribution don't give answer for things like safety and strength.
Technical codes is right source for these issues.


 



CalculixLauncher License

CalculX Launcher is free collection of software (pre-post processors, mesh converters and other tools) distributed for free, for private and commercial use, WITHOUT ANY WARRANTY.

CalculX Launcher binary files is Free Software (Common Creative -ShareAlike 2.5 Generic CC BY-SA 2.5)
Source code is stored at /scr/Lazarus_Launcher...
It is based on modified version of CalculiX CGX (come additional cards added by Sergey Pustovoitoff)   Source code is stored at /scr/CalculiX...


CalculiX is free software; you can redistribute it and/or modify 
it under the terms of the GNU General Public License as published by 
the Free Software Foundation; either version 2 of the License, 
or (at your option) any later version.

This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; 
if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 

Gmsh is “free software”; this means that everyone is free to use it and to redistribute it on a free basis. It is provided under the terms of the GNU General Public License (GPL), Version 2 or later, with the some exceptions
(Read GMSH help file for more details)

Converters come with source code, stored in the ../scr/Converters folder

UNV to INP converters

UNICAL - CalculiX interface program,  Bernhardi, Aug 2011, with some changes. 

UNV2X base code, J.Cugnoni, www.caelinux.com,9.2006 with some modifications

 GMSH INP to CCX INP

is under GPL Version 2 license 
comes as free collection of python scripts with py files.

The objective of distributing this collection of free open-source software is to help professional engineers, students and hobbyists with studying main principles of FEA and  CAD. Since open-source programs are developed by independent teams, there are many problems with compatibilities of file formats and open libraries. Distribution of statically linked binaries is helpful for beginners to start working without investigation of why it doesn't work and  why old published samples can not be reproduced on new versions



Caelinux+CalculiX Launcher Under VirtualBox

CalculiX is native linux software. It means that it is writing and testing primarily for linux. Since GCC compiler is cross-platform, CalculiX is ported to Windows, but it is not free from mistakes and problems.
For example CCX (solver) don't pass all verification tests.
CGX (Pre, Post-processor) has many small mistakes (all known builds).
It doesn't matter for small models in 90% of cases, and it is hard to catch and fix them all, because compilers have many small differences.
Also Windows XP, Windows7 and etc, may work differently, even with some new updates. Sometimes it works at Windows7 at home but don't work in other place. It is not so easy to catch all these problems for all windows users in limited time (also, remember that it is free, and  I don't care of all people too much).

It is why CalculiX Launcher for Windows is limited. Also, for same reason, I provide two versions of CGX for Windows:  2.5 and 2.10 (old one is more stable, new one has more functions).

Trying to avoid all these problems and minimize my work, I am suggesting you to use CalculiX under Linux. If you're experienced linux user, you probably have both systems (in dual boot).  Linux can be installed on removable usb drive. Also many people use linux only (engineers with Siemens NX and etc). The other benefit that Salome-Platform is also native linux software, and Salome_MECA (with Code_Aster) don't even have port to Windows.

If you don't know what is linux, you can install it under VirtualBox. In this case you have minimal risk to damage something when installation and finally your linux will be running as regular Windows program.

It is good solution if you have enough memory to run both OS at the same time.
Let's assume that practical minimal portion of RAM, set up for linux in virtualbox,  is about 2.5-3 GB (you also should leave enough amount of RAM for Windows and other windows software). it is not a problem if you have 6-8 GB total amount RAM on your PC.
Disk space should be about 50 GB (to work with comfort, install software, create large models and don't think about free space).
You should setup these limits at the beginning of creation of linux image.

ISO files for linux can be downloaded anywhere. Remember that there is difference between amd64 (x86-64) and i386 (32 bit) architecture. Get right ISO file, that matches your virtualbox setup.
64 bit is recommended for calculation deals because it gives you ability to run large models.

I would recommend you caelinux distribution (64bit) that comes with many engineering programs. Alternative link for ISO files (caelinux2013.zip) is here.
Also you will need to update Salome-MECA to newer version (2015-2016) which is more efficient than 2013 (in caelinux2013 collection).
For 32-bit system you may obtain only Salome-MECA2013 (they stopped providing 32bit for old computers now). 


Please, see the movie , how to do it.

Note: don't update Caelinux to Ubuntu14! It will require some specific work to fix some issues after updates. Linux is not windows, so don't worry for viruses too much.
Just keep your Internet browser and adobe-flash updated (because it is main source of possible threats).


Wizard for CalculiX - Screenshots









Manager of Groups














Manager of graphs (*AMPLITUDE, nonlinear springs and etc)













Applying linear contact



Getting Started With CalculiX Launcher For Windows

As it was mentioned, CalculiX Launcher works with Salome-Platform.
Salome-Platform is 'papa' of FreeCAD and many others free CAD programs. It has the same functions and STEP/IGES support.

First, go the the official web-site and download Windows version (registration is required). For 32-bit Windows you may need to get older version.
http://www.salome-platform.org/downloads/previous-versions/salome-v7.4.0
This is test of Salome7.4.0 on Windows XP sp2, Home Edition.

You will obtain self-extracting archive for Windows (about 1gb of size)










Unzip it onto C:\ drive












This procedure may take some time, but the benefit of huge size is portability.
Salome-Platform will provide you software with all libraries. Normally it should work 'out of box' but in some cases you may read installation instruction
Go to the folder with Salome and run 'bat' file as it is shown below.












At Windows7 you may need 'allow access', just do it.











OK, done! You can see Salome-Platform with list of modules. Start with selection of GEOM module.

Video lessons below show you main steps of how to work in CalculiX.

To learn Salome from scratch see this playlist.

Video-Lesson1 - Creating and meshing model in Salome-Platform.

 
Video-Lesson2 - Converting mesh into CalculiX format and running CGX in Pre-Processor mode.

 

Video-Lesson 3 - Creating INP file with commands for CalculiX CCX (solver)


Video-Lesson 4 - Running CalculiX CGX in Post-Processor mode

 

There are some video lessons of using text editor with code snippets, to apply boundary conditions. This is useful option for Windows (instead of wizard)
See it here: 1, 2, 3


CalculiX and Salome-Platform are native linux programs. They mainly developed and tested for linux. All windows clones are not free from mistakes.
In this case you may use CalculiX Launcher with windows version, provided by Jeff Baylor. http://bconverged.com/
It is most stable version of CalculiX for Windows, and sometimes it can be helpful.
The other (best) way is to install linux under Windows with Virtualbox
Google how to do it, also you may use this version, with old Salome-MECA pre- installed.