Mr. Tanzil Tjhin 0 Report post Posted September 14, 2014 Hi guys, I want to generate an external file which consists changable variable(p1,p2). So I use sobol to produce these random values. The roundup is as follow: create external file output from framework, run the external program and throw the results back on framework to be analysed. My problem is how do I save the produced values for every index (variant) and not only the last step after sobol? it seems that I miss a bunch of required objects/attributes. Any idea? Regards,Tanzil simple example: unsigned n(20)designvariable p1(5)designvariable p2(10) de_sobol Sobol()Sobol.setNumberOfVariants(n)Sobol.setDesignVariables([[p1, 3, 7, true], [p2, 8, 12, true]]) Sobol.run() // Here: temporary saving ??? loop(n) string workingDir(getDesignDir() + "/" + this.getName() + "/" + $$i + "/")mkpath(workingDir)FFile out(workingDir + $$i + ".txt")out.openWrite()// Here: variable values for every iterationout.write()out.close() endloop Share this post Link to post Share on other sites
Karsten Wenzke 12 Report post Posted September 14, 2014 Hey Tanzil, First of all I'm not hundred percent sure what you really want to save and how.But at the moment you have not definied any values to be saved in a file. Here is my code: unsigned n(20) designvariable p1(5) designvariable p2(10) de_sobol Sobol() Sobol.setNumberOfVariants(n) Sobol.setDesignVariables([[p1, 3, 7, true], [p2, 8, 12, true]]) Sobol.run() // Here: temporary saving ??? loop(n) string workingDir(getDesignDir() + "/" + this.getName() + "/" + $$i + "/") mkpath(workingDir) FFile out(workingDir + $$i + ".txt") out.openWrite() // Here: variable values for every iteration out.write("p1:" + p1) out.write("p2:" + p2) out.close() endloop this saves p1 and p2 for every variant in the defined text file. I simply modified the line fourth and third last lines. This feature will create for every variant (20) a text file.If you need more output simply add more "write()" statements. Here is another thread for a t-search encapsulated in a feature.Hope this helps. If you have further questions do not hesitate to ask. :-) Cheers, Karsten Share this post Link to post Share on other sites
Ben Zeitz 1 Report post Posted September 15, 2014 Hi Tanzil, I wonder why you want to run the the sobol from within a feature?As far as I can see you could accomplish it more easily by just setting up a template in the software connector.Or do I miss something? See Documentation Browser -> Tutorials -> External Software in CAESES for a step by step tutorial on how to set up a software connector.(Additionally I attached the tutorial here) Cheers,Ben04_External_Software.pdf Share this post Link to post Share on other sites
Mr. Tanzil Tjhin 0 Report post Posted September 16, 2014 Hi Karsten and Ben, I'm currently working with evacuation simulation tools called FDS+Evac. Issue is the input geometry and the informations that control the external software are in one single file. Moreover it doesn't support any export geometry file such as stl, dxf, etc. In short, I don't create nor export any geometry from caeses/ffw. The external software read and generate the geometry (rectangle) independently. This is the reason why I dont use software connector. The input file is as follow: &HEAD CHID='DoorFlowExample', TITLE='door flow test, 2.0' / door width 2.00 m, (dw=0.2m) &MESH IJK=150,150,1, XB=0.0,15.0, 0.0,15.0, 1.45,1.55, EVACUATION=.TRUE., EVAC_HUMANS=.TRUE., EVAC_Z_OFFSET=1.5, ID= 'FF1stFloor' / &TIME T_END= 200 , DT=0.1 /... geometry:&OBST XB= 0.0, 15.0, 0.0, 0.1, 0.0,2.0, /&OBST XB= 0.0, 0.1, 0.0,10.0, 0.0,2.0, /&OBST XB= 14.9, 15.0, 0.0,10.0, 0.0,2.0, /&OBST XB= 4.9, 5.0, 10.0,15.0, 0.0,2.0, /&OBST XB= 10.0, 10.1, 10.0,15.0, 0.0,2.0, /&OBST XB= 0.0, 15.0, 10.0,10.1, 0.0,2.0, /&HOLE XB= 6.5 , 8.5, 10.0,10.1, 0.0,2.0, / so, my first idea is to replace some of this numbers by variable values. I guess it would work with sobol, which give me a random values and then I save it for every design. Is it possible this way? The code written by Karsten have been on my mind. It doesn't work as I want. It's only save the same or last variable values for every variant/design (in this case 20 times). Any advice what else I can try? Cheers,Tanzil Share this post Link to post Share on other sites
Ben Zeitz 1 Report post Posted September 16, 2014 Hi Tanzil, Yes, I guess that should be possible.You still should use the software connector, though.Set up an input template as you described above up to the part where the geometry begins. Replace all needed values with so called entries (the GUI should automatically offer entries for numbers in the template, just chose the wished ones). Then set the proper designVariables (the ones you use in the sobol) as values of the entries.Now half of the needed input file is ready. The geometry file is generated by an extern application, right?How about creating a small batch file which merges the input template and the geometry file into one input file for your evac-code? (Assuming it is easy to merge, the geometry just written straight after the other input values.)After merging process the batch file has to execute the evac-code with the new created input file.Then set the batch file as application in the computation of the software connector.That's all, run the computation to see if it works. I hope that will do the trick? Another approach could be to create the input file entirely in a feature. (Just create the file, there still seems to be no reason to run the sobol in the feature.)That would shift the task from batch-programming to feature-programming.Here's an example of my colleague on how to do it:http://www.friendship-systems.com/forum/index.php?/topic/159-exporting-custom-file-formats-using-features/ Good luck!Ben Share this post Link to post Share on other sites
Mr. Sebastian Weickgenannt 1 Report post Posted September 17, 2014 Hi Tanzil, In addition to what my collegues mentioned, you should be aware, that the Sobol does NOT give you (pseudo-) random numbers.It is a sequence, which will always return the exact same values, if you don't change the boundaries for the design variables. Therefore the generation of a Sobol design engine within a feature will always yield the same n sets of p1 and p2 each time you execute the feature. The Sobol sequence covers the design space way more evenly than pseudo-random numbers and might therefore be well suited for your task (?). Read more on the Sobol here: http://en.wikipedia.org/wiki/Sobol_sequence If you want pseudo-random numbers instead, you could use the command rand(), which returns values between zero and one. I.e. rand()*4+3 returns pseudo-random values between 3 and 7. Cheers,Sebastian Share this post Link to post Share on other sites
Mr. Tanzil Tjhin 0 Report post Posted September 18, 2014 Hi Sebastian, Thanks a lot for the information. The Sobol sequence is indeed more suited for this task. By now, it works with software connector as Ben suggested. I just need to complete the batch script as my needs. Cheers,Tanzil Share this post Link to post Share on other sites
Mr. Sebastian Weickgenannt 1 Report post Posted September 18, 2014 Great! Good luck! Cheers,Sebastian Share this post Link to post Share on other sites