Monday, August 27, 2012

[Matlab] fast reading of huge ASCII input files

The following code provides a rather fast way to deal with large ASCII data files containing groups of sub-data with different numbers of columns. For N=1E6 (leading to a ~2 M lines input file), the reading takes ~5 sec while the data reconstruction in matrix form lasts ~55 sec (on a 2012 laptop PC).

% Cleansing
clear all;
clc;

% Input Data
N=1E6;
x = 0:pi/N:pi;
y = [x; cos(x)];            %2 columns
xx= pi:pi/N:2*pi;
yy = [xx;cos(xx);sin(xx)];  %3 columns

% ASCII file writing
fprintf('* writing\n');
tic;
pfile = fopen('data.txt', 'w');
fprintf(pfile, '%12.8f %12.8f\n', y);
fprintf(pfile, '%12.8f %12.8f %12.8f\n', yy);
fclose(pfile);
toc;

% ASCII file reading
fprintf('\n* reading\n');
tic;
pfile=fopen('data.txt');
InputText=textscan(pfile,'%s','delimiter','\n');
fclose(pfile);
NN=length(InputText{1,1});
toc;

% Data matrix creation
fprintf('\n* matrix creation\n');
tic;
A=zeros(NN,3);
for i=1:NN
    line=InputText{1,1}{i,1};
    [str,count] = sscanf(line, '%s');
    if count == 2
        A(i,1:2)= sscanf(line, '%f %f');
    elseif count == 3
        A(i,1:3)= sscanf(line, '%f %f %f');
    end
end
toc;

Friday, June 8, 2012

[Abaqus] launching abaqus in command line

an example handling: the number of cpus involved, the memory allocation, the scratch directory :

abq610 job=MyJob cpus=12 memory=150GB scratch=/home/AbqScratch

Abaqus Finite Element Software:
http://www.simulia.com/

[Linux] permissions modification

When working on a server shared with other users, it seems suitable to restrict the access to personal files/directories.

The use of the command "chmod" can trigger rights for execution (+1), writing (+2) and reading (+4). Three perimeters are considered: the user (1st digit) , the usersgroup (2nd), everybody (3rd).

If one wants to restrict the access to his directory /home/MyRep for himself only, the command is then "chmod -R 700 /home/MyRep".

Ubuntu Linux distribution:
http://www.ubuntu.com/

Tuesday, April 3, 2012

[Abaqus] edition of viewport parameters

if one wants to modify the size/color/font/activation... of the written data displayed in the viewport, that's the place :

viewport/viewport annotation options (CAE 6.10-1)

Abaqus Finite Element Software:
http://www.simulia.com/

Sunday, November 6, 2011

[Maths] Series convergence tests

Usually d'Alembert's ratio test is easier to perform than Cauchy's root test but it is less powerful (-> book Advanced mathematics for applications, Andrea Prosperetti, Cambridge University press).

On Amazon:
http://www.amazon.com/Advanced-Mathematics-Applications-Andrea-Prosperetti/dp/0521735874
On Google Books:
http://books.google.com/books?id=yQejXXN8zdoC

Wednesday, November 2, 2011

[LATEX] Re-installation

A far more tedious task than I remembered...

With a few blocking points:

* Installation of miktex:
configuration of the proxy : proxyweb.xxx.xx + port 3128 (not 8080 for me !!!)

* Compilation issue with an old miktex version :
error message:
! You are attempting to make a LaTeX format from a source file
! That is more than five years old.
solution:
edit \MiKTeX 2.8\tex\latex\base\latex.ltx
and change \ifnum\count@65 to \ifnum\count@165

* TexnicCenter tex=>pdf (with .eps images)
copy the basic tex=>.ps profile and add a postprocessor:
gs\gs9.04\bin\gswin64.exe
-sPAPERSIZE=a4 -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="%bm.pdf" -c save pop -f "%bm.ps"

Miktex (Latex for Windows):
http://miktex.org/
Texniccenter (Latex environment for Windows):
http://www.texniccenter.org/
Latex softwares (including the all-in-one solution Protext for Windows)
http://tug.org/texcollection/

Thursday, October 27, 2011

[Abaqus] - Hidding elements' edges

* with the mouse:
view/part display options/show edges in shaded render style

* with python:
session.viewports['Viewport:1'].partDisplay.meshOptions.setValues(meshEdgesInShaded=OFF)

Abaqus Finite Element Software:
http://www.simulia.com/