cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Prime Parametric Finite Element Modelling Using Text Files

terryhendicott
21-Topaz I

Prime Parametric Finite Element Modelling Using Text Files

Hi All

 

This is my first post for help so bear with me.

 

I want to use Prime for what used to be fast and easy in Mathcad 15.

 

I have a work round but it is so slow so asking the forum if there is a better faster way in Prime.

Perhaps a future scriptable data file saving component?

 

First what was possible in Mathcad 15

 

Mathcad 15 had a data file export component.

This data file export component when you selected "Formatted Text" did four things

1) Text in double quotes ended up in text file with single quotes

2) Text in single quotes lost the quotes in the text file

3) Adjacent quotes "" to indicate no data did not appear in the text file.

4) Numbers stayed as numbers

In this way a very large text file could be generated from a Mathcad matrix quickly

 

Here is a simple example.

Capture.JPG

 

Primes current file output functions cannot duplicate this Mathcad 15 data components behavior.

 

Second how I got around the limitation.

I created a function that uses str2vec to create a giant column vector of ascii characters, but it is agonizingly slow.

For instance a Prime file with a matrix of 99514 rows x 8 columns with 4.5 million characters takes about half an hour in Prime to calculate and save the large column vector.  The vector is saved by WRITEBIN function.  Half an hour for hundreds of parametric files is a long time I am not looking forward to.  Hence my call for help.

 

Can anyone speed up the function or suggest a faster method of creating the file in Prime.

Capture2.JPG

 

This is what the finished finite element model looks like generated from a few parameters using Prime.

My aim is to save steel tonnage in portal frame buildings.

Capture4.jpg

Thanks Terry

ACCEPTED SOLUTION

Accepted Solutions

Hi,

Have got a work round until PTC update Prime with a proper space delimited file saver.

Thanks Luc for setting me on this thought process.

Workaround involves Mathcad 15, so much for Prime alone

Step 1

Save a text file with Prime this gets a text file that can be imported into Mathcad 15

Capture.JPG

The file has single quotes for single quote entries

Triple quotes for double quote entries

Look at the "Group" lines and you can see the Prime text saver is random in treating numbers as text or numbers but no matter this workaround negates that.  Who knows how many times it does this in the large file.

Capture2.JPG

Step 2

Run a Mathcad 15 file with only two statements using the built in file input and output components

This gets a file with single quotes gone and triple quotes as double quotes.

Note this fixed the group statements and codes are now integers like they should be.

Numbers are accurate not like WRITEPRN() statement in Prime.

Capture3.JPG

Capture4.jpg

Step 3

Replace in an ASCII editor the double quotes to single quotes and save.

Step 4

Run the FEM program and import the file.

Round trip time a couple of minutes.

 

A tedious kludge but it is going to save hours.

 

Cheers

Terry

View solution in original post

11 REPLIES 11

I, too, can't think of anything else than creating the large vector and using WRITEBIN.

I won't claim that my function in the attached file would be any faster than yours, but you sure have the large data at hand to testdrive it.

Werner_E_3-1665547915300.png

 

It looks to me that your version adds a blank line at the top of the output file. If thats OK for you you can change in my function the ["dummy line"] for [13,  10] and delete the submatrix command at the end.

Of course you may also change my CR LF (13, 10) for CR (13) only if that suits your needs better.

 

 

Thanks Werner

I'll give it a go and get back.

Cheers

Terry

Hi Werner

Have been doing some testing and examination.

 

There are nearly 800,000 items in the matrix.  Majority of them are numbers.

 

AssemblyPRN() uses only one branch if/else test for this majority of items as numbers

Strings either "" or with values like "Quad4" only have to pass two if tests.

AssemblyPRN() takes 27 minutes to run.

 

FileOutput() performs three if tests for each item no matter what the item is so runs for a longer time

Currently at 1 hour 30 minutes and still not finished.

 

Think I will look at the Prime API over the next couple of days but not hopeful.  The API is set up to pass a matrix of numbers or individual strings as variables.  Does not look to cover a matrix made of strings and numbers?  

 

Cheers

Terry

 

Too bad!

I have no experience with the API but I seem to remember that the limitations of it when it comes to matrices was already discussed here in the forum a few times.

Here is a version where only one "if" is left.

But I fear that the operations done on a huge matrix M to create the new(!) matrix M2 may more than compensate for the saved if-statements. Guess that the additional memory consumption should not be a problem for Prime (it could have been a problem in real Mathcad).

Give it a try if you feel like doing so.

If its no problem that empty strings result in Null bytes you may remove the "trim" line

if its no problem that the file start with a CR(13) you can delete the "submatrix" line

Werner_E_3-1665594746512.png

 

EDIT: A first timing test is not promising but its just using your 3x3 data matrix and so may not be a good indicator for how the functions would scale for larger matrices...

Werner_E_4-1665594902616.png

EDIT2:

I guess its not necessary that you test the new function with your large data matrix. I stacked and augmented your demo matrix to create just a 30x30 data matrix and here are the results:

Werner_E_0-1665596181740.png

It looks that so far your AssemblePRN is by far the fastest solution 😉

 

Why don't you use WRITEPRN, then (using you favourite ascii editor) strip off the heading, remove all single quotes and replace double quotes with single quotes?

 

Success!
Luc

Hi Luc

 

WRITEPRN was my first go to.  It takes the snap of the fingers to save the file not 27 minutes but!

The output from WRITEPRN is rubbish and enclosed should show you why.

WRITEPRN:-

Rounds decimal numbers, Mathcad 15 had two worksheet variables to cover column width and precision

Sometime interprets a large integer as text not a number

Sometimes puts a large integer in scientific format thus loosing information

Each line is all over the place.

 

27 minute file is ordered and looses no data.  This is formatted text output Mathcad 15 used to be able to do

Capture.JPG

WRITEPRN is rubbish because it looses important data

Capture2.JPG

Cheers

Terry

 

Hi All,

 

Really want PTC to realize how useless WRITEPRN is

Capture.JPG

The beams are connected to two nodes given by the numbers in the last two columns

Here is how WRITEPRN interprets this.

Capture2.JPG

Beam 1,2,3, & 4 all now go between nodes 17320 and 17800 this is not what is intended?

Node 52380 is written five times?

WRITEPRN() looses valuable information of the FEM model.

Cheers

Terry

Hi,

Have got a work round until PTC update Prime with a proper space delimited file saver.

Thanks Luc for setting me on this thought process.

Workaround involves Mathcad 15, so much for Prime alone

Step 1

Save a text file with Prime this gets a text file that can be imported into Mathcad 15

Capture.JPG

The file has single quotes for single quote entries

Triple quotes for double quote entries

Look at the "Group" lines and you can see the Prime text saver is random in treating numbers as text or numbers but no matter this workaround negates that.  Who knows how many times it does this in the large file.

Capture2.JPG

Step 2

Run a Mathcad 15 file with only two statements using the built in file input and output components

This gets a file with single quotes gone and triple quotes as double quotes.

Note this fixed the group statements and codes are now integers like they should be.

Numbers are accurate not like WRITEPRN() statement in Prime.

Capture3.JPG

Capture4.jpg

Step 3

Replace in an ASCII editor the double quotes to single quotes and save.

Step 4

Run the FEM program and import the file.

Round trip time a couple of minutes.

 

A tedious kludge but it is going to save hours.

 

Cheers

Terry

Hi All,

 

Have created a command line C++ parser that takes the tab delimited output of Primes WRITETEXT() with all its quotation marks and writes a space delimited formatted text file like the Mathcad data component.

Parser reads an entire directory of files and saves the new files in a subdirectory.

Lightning fast.  The 27 minutes is now down to a few seconds per file. 

 

Cheers

Terry

Hi All,

 

For completeness here is the DirectoryTest.cpp C++ coding in a zip file.

Cheers

Terry

Announcements

Top Tags