Using XML output

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
Andrew
Posts: 12
Joined: Wed Apr 06, 2005 7:28 pm
Location: Arup

Using XML output

Post by Andrew »

What are the ways that we can use the XML output? I can see that it is quite powerful, but I am not sure what tools are out there already. I would like to be able to graph the data, but also to be able to do text processing to generate output data that I can read into visualisation programs.

I am using a Mac, so I have been looking for programs that will work on that platform.

I have tried opening the .xml files in Excel, but they come in as text. I have been looking at XQuery, which seems quite promising, but I am not sure what sort of queries to run, particularly on the <data> blocks, which seem to need postprocessing with something like sed or awk. I have found a little program called AquaQuery, which allows me to play with queries, but doesn't really do any of the heavy lifting. It also doesn't reference the schema.

What are other people using? Am I going to have to do some programming in PHP using XQuery, or something like that? How do I use the schema... and should I be doing so...(presumably yes!)...
silvia
Posts: 3909
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers
Contact:

Post by silvia »

why not just do it in Tcl/Tk?
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
Andrew
Posts: 12
Joined: Wed Apr 06, 2005 7:28 pm
Location: Arup

Post by Andrew »

[quote="silvia"]why not just do it in Tcl/Tk?[/quote]

Yes, that would certainly make sense. However, the question remains as to what tools to use with Tcl/Tk to query XML data? Would you use parsing (and other) tools such as those in TclXML package on SourceForge (SAX, DOM or XSLT)? Do you have any sample code for extracting time domain results that could be used to write a graph? All that data under <data> needs processing as text, unless there is some way that the schema helps to interpret it (which I am not currently familiar with).

[url=http://tclxml.sourceforge.net/][/url]
(or perhaps tDOM - [url=http://wiki.tcl.tk/1948][/url])

I have taken a look at BuildingTcl. Can I use that on a Mac? What would I need to do? Should I rewrite the BAT files as a script?

Another thing that would be good would be if I could pull the data straight into excel. Presumably I could use something like MSXL, although I presume it is now superseded by a method in VSTO.

[url=http://msdn.microsoft.com/en-us/library ... 10%29.aspx][/url]
silvia
Posts: 3909
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers
Contact:

Post by silvia »

i don't know much about xml
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
Andrew
Posts: 12
Joined: Wed Apr 06, 2005 7:28 pm
Location: Arup

Post by Andrew »

Silvia,

As a matter of interest, how are you extracting the data for your BuildingTcl program?
aneeman
Posts: 90
Joined: Thu Jan 12, 2006 1:13 pm
Contact:

opensees xml

Post by aneeman »

You will need to do a little postprocessing first on the xml, if for example, you want to use php to do some analysis.

The current format is really a table, with the
column names first in XML format, and the table data inside a single data tag.
e.g.

<TimeOutput>
<ResponseType>time</ResponseType>
</TimeOutput>
<NodeOutput nodeTag="3" coord1="20.000000" coord2="0.000000" coord3="0.000000">
<ResponseType>D1</ResponseType>
</NodeOutput>

<Data>
1.000000 0.028159
2.000000 0.056318
</Data>

To be able to truly use it as XML you would have to reformat it. (See below. )then you
could use xpath for queries (libraries in java and php, possibly other languages), I also like sax and dom (implemented in java and c++ ; google xerces and jaxp for more info).

<Timestep>
<TimeOutput>
<ResponseType name="time">
<Data>1.000000</Data>
</ResponseType>
</TimeOutput>
<NodeOutput nodeTag="3" coord1="20.000000" coord2="0.000000" coord3="0.000000">
<ResponseType name ="D1"><Data>
0.028159</Data>
</ResponseType>
</NodeOutput>
</Timestep>

<Timestep>
<TimeOutput>
<ResponseType name="time">
<Data>2.000000</Data>
:
</Timestep>
dborello
Posts: 26
Joined: Fri Sep 05, 2008 11:00 am
Location: University of Illinois at Urbana-Champaign

Post by dborello »

I used the code below to read the xml output in MATLAB. It reads displacements, reactions and element forces from the xml recorders. It also regenerates node locations and element connectivity. The output should be obvious....

It requires xml_read (mathworks.com/matlabcentral/fileexchange/12907-xmliotools).

I used the following recorders:
recorder Node -xml $DataDir/NodeDisplacements.txt -time -nodeRange 1 $NNodes -dof 1 2 disp;
recorder Node -xml $DataDir/Reactions.txt -time -node 1 $NNodes -dof 1 2 reaction;
recorder Element -xml $DataDir/Elements.txt -time -eleRange 1 $NElements globalForce;

It turns out that it is actually really slow, so I haven't used it in over a year. Therefore you are on your own for debugging.

[code]
function [Nodes, Elements, Time] = ReadOpenSees(path)

%% Read node data
Pref.Str2Num = 'always';
xml_Struct = xml_read([path '/NodeDisplacements.txt'],Pref);

%...Is there time?
if isfield(xml_Struct.OpenSeesOutput,'TimeOutput')
Time = xml_Struct.OpenSeesOutput.Data(:,1);
offset = 1;
else
offset = 0;
end

%...Number of DOFs
ndof = length(xml_Struct.OpenSeesOutput.NodeOutput(1).ResponseType);

%...Place coordinates and displacements in Nodes structure
for i = 1:length(xml_Struct.OpenSeesOutput.NodeOutput)
Nodes(xml_Struct.OpenSeesOutput.NodeOutput(i).ATTRIBUTE.nodeTag,:).cord...
= [xml_Struct.OpenSeesOutput.NodeOutput(i).ATTRIBUTE.coord1 xml_Struct.OpenSeesOutput.NodeOutput(i).ATTRIBUTE.coord2];
Nodes(xml_Struct.OpenSeesOutput.NodeOutput(i).ATTRIBUTE.nodeTag,:).u...
= xml_Struct.OpenSeesOutput.Data(:,offset+i*ndof-(ndof-1):offset+i*ndof);
end


%% Read reactions
Pref.Str2Num = 'always';
xml_Struct = xml_read([path '/Reactions.txt'],Pref);

%...Is there time?
if isfield(xml_Struct.OpenSeesOutput,'TimeOutput')
Time = xml_Struct.OpenSeesOutput.Data(:,1);
offset = 1;
else
offset = 0;
end

%...Number of DOFs
ndof = length(xml_Struct.OpenSeesOutput.NodeOutput(1).ResponseType);

%...Place reactions in Nodes structure
for i = 1:length(xml_Struct.OpenSeesOutput.NodeOutput)
Nodes(xml_Struct.OpenSeesOutput.NodeOutput(i).ATTRIBUTE.nodeTag,:).cord...
= [xml_Struct.OpenSeesOutput.NodeOutput(i).ATTRIBUTE.coord1 xml_Struct.OpenSeesOutput.NodeOutput(i).ATTRIBUTE.coord2];
Nodes(xml_Struct.OpenSeesOutput.NodeOutput(i).ATTRIBUTE.nodeTag,:).F...
= xml_Struct.OpenSeesOutput.Data(:,offset+i*ndof-(ndof-1):offset+i*ndof);
end

%% Read Elements
Pref.Str2Num = 'always';
xml_Struct = xml_read([path '/Elements.txt'],Pref);

%...Is there time?
if isfield(xml_Struct.OpenSeesOutput,'TimeOutput')
Time = xml_Struct.OpenSeesOutput.Data(:,1);
offset = 1;
else
offset = 0;
end

%...Number of fields
nfields = length(xml_Struct.OpenSeesOutput.ElementOutput(1).ResponseType);

%...Place element connectivity and forces in Elements structure
for i = 1:length(xml_Struct.OpenSeesOutput.ElementOutput)
Elements(xml_Struct.OpenSeesOutput.ElementOutput(i).ATTRIBUTE.eleTag,:).con...
= [xml_Struct.OpenSeesOutput.ElementOutput(i).ATTRIBUTE.node1 xml_Struct.OpenSeesOutput.ElementOutput(i).ATTRIBUTE.node2];
Elements(xml_Struct.OpenSeesOutput.ElementOutput(i).ATTRIBUTE.eleTag,:).F...
= xml_Struct.OpenSeesOutput.Data(:,offset+i*nfields-(nfields-1):offset+i*nfields);
end
end
[/code]
silvia
Posts: 3909
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers
Contact:

Post by silvia »

i create my model data from the beginning and use it to create the opensees model and the post-processing.
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
Post Reply