I have been doing a very repetitive series of simulations for a while and would like to automate the process so that I can enter a few parameters and walk away while the software does the work for me. Since there is no macro recorder for flow, I was looking at the example Excel file that uses Visual Basic (from the api sdk 2011\\vb_sample folder). I am able to use this to start SW, open a flow model, and successfully run multiple simulations while incrementing a value like mass or volume flow rate, but what I need to do is change inlet and environmental concentrations in a transient problem based on the outlet concentration from the previous time step. Here is the procedure I follow when running a new simulation:
1. Change maximum simulation time to 10 seconds. The time step is set to 10 seconds.
2. Set the starting Inlet Volume Flow and Environmental Pressure concentrations for air and H2S using F(time) tables, so that at time zero the H2S concentration is 65 ppm and air is 999935 ppm (for example).
3. Run solver.
4. When solver is done, look at Surface Parameters for two slots where air escapes the model, Average Volume Concentration of H2S. This is the concentration of H2S escaping through the slots at the end of the time step. There is also a Surface Goal Volume Fraction of H2S set up in the simulation, and I know the API allows this to be used.
5. Add the concentration from step 4 to the F(time) table for Inlet Volume Flow and Environmental Pressure concentrations for time = 10 seconds.
6. Increment the maximum simulation time by 10 seconds.
7. Run solver again, but continue the calculation.
8. Repeat from step 4 until the desired number of time steps has been reached (90 seconds for example).
9. Finally, run the simulation one more time, using the maximum simulation time of 90 seconds and the complete F(time) table that was created so that the results files will be saved for all time steps (for some reason when I do the individual steps, only the last results file gets saved and the earlier ones get deleted).
I would like to be able to enter initial concentration, starting Inlet Volume Flow and Env Pressure concentration, total simulation time, time step size, and number of solver iterations in an Excel spreadsheet and run a program that will do all of this for me automatically, possibly incrementing the starting concentration (50 ppm, 55 ppm, 60 ppm, etc) with each iteration.
I looked through the Flow Sim API help file but could not find any way to change the concentration values within a dependency table. Does anyone have any code snippets they have written that would show me how to do this, or possibly have a complete list of the VB class structure/hierarchy for Flow Simulation? It seems like there are a lot of things missing or unlisted in the help file. I'd like to do this in VB initially since the Excel interface is very convenient for my purposes at the moment.
Any help is much appreciated! I am able to manually do all of this in approx. 15 minutes for each new set of conditions for a 120-second simulation, but it is very repetitive and I have a schedule of probably 50+ simulations I need to run, so I decided it was time to start looking at the API. I think an F(goal) equation could do this, too, but that is not available for concentrations.
- Dan
SolidworksApi macros