CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Run each simulation based on initial condition of previous run results (https://www.cfd-online.com/Forums/cfx/159106-run-each-simulation-based-initial-condition-previous-run-results.html)

bejanyar September 9, 2015 00:55

Run each simulation based on initial condition of previous run results
 
Hello.
I face a new problem !
I have a simulation that contain a fixed geometry and mesh and several pressure boundary condition.
I reed other post in this forum to automatically change pressure and run several time.
I did this:
I made a cfx analyze system and defined parameter for pressure boundary condition. then i duplicate it and change the parameters and continue to duplicating and changing parameters until all pressure finished.
Updating setup cells and updating solution cell.
Runs send to RSM and execute 1 by 1 automatically.
The problem in that i want each run based on initial condition of previous run result. But because cfx , cfx 1 , cfx 2 , cfx 3 , cfx 4 , ..... have different working directory this not happen.
How can i do this ???
And is my way for doing some repetitive job for several pressure correct ?

ghorrocks September 9, 2015 03:23

This is easy to do using the command line to start the jobs. Just define the initial condition as the result file from the previous run.

I am no expert on running this stuff under RSM so I cannot say for how it is done that way.

bejanyar September 9, 2015 03:48

Yes, I know i can set initial condition on "Update from current solution data if possible" .
But problem is that this option use current solution data in that case.
but in my problem there is cfx , cfx1 , cfx2 , ...
how to use last result of cfx , in initial condition of cfx 1 ??
And about command line , i know nothing !!! How can i do this using command ? and where is it ?? in WorkBench ? in cfx setup ??

ghorrocks September 9, 2015 06:08

I always prefer the command line options when doing anything like what you propose. That way you can directly specify what is input to what.

Have a look in the documentation under "Starting CFX from the Command Line".

bejanyar September 15, 2015 14:16

Ok,
I did it using command line:

Code:

# encoding: utf-8
# Release 16.1
SetScriptVersion(Version="16.1.91")
i = 1
while (i < 3):
       
        j=1
        while (j < 10):
                designPoint1 = Parameters.GetDesignPoint(Name="0")
                p1 = Parameters.GetParameter(Name="P1")
                p2 = Parameters.GetParameter(Name="P7")
                p3 = Parameters.GetParameter(Name="P8")
                p1v = designPoint1.GetParameterValue(Parameter=p1)
                p2v = designPoint1.GetParameterValue(Parameter=p2)
                p3v = designPoint1.GetParameterValue(Parameter=p3)
                dp1 = Quantity ("10 [degree]")
                dp2 = Quantity ("10000 [Pa]")
                dp3 = Quantity ("100000 [Pa]")
                p2v = p2v + dp2
                p93v=p2v
                p2v = str ( p2v )
                designPoint1.SetParameterExpression(
                        Parameter=p2,
                        Expression=p2v)

                system1 = GetSystem(Name="CFX")
                setup = system1.GetComponent(Name="Setup")
                setup.Update(AllDependencies=True)
                solution = system1.GetComponent(Name="Solution")
                solution.Update(AllDependencies=True)
                results = system1.GetComponent(Name="Results")
                results.Update(AllDependencies=True)
                solution = system1.GetContainer(ComponentName="Solution")
                solution.ClearOldSolutionData(KeepReferenced=False)
               
                p4 = Parameters.GetParameter(Name="P4")
                p5 = Parameters.GetParameter(Name="P5")
                p6 = Parameters.GetParameter(Name="P9")
                p7 = Parameters.GetParameter(Name="P10")
                p8 = Parameters.GetParameter(Name="P11")
                p9 = Parameters.GetParameter(Name="P12")
                p10 = Parameters.GetParameter(Name="P13")
                p11 = Parameters.GetParameter(Name="P94")
                p4v = designPoint1.GetParameterValue(Parameter=p4)
                p5v = designPoint1.GetParameterValue(Parameter=p5)
                p6v = designPoint1.GetParameterValue(Parameter=p6)
                p7v = designPoint1.GetParameterValue(Parameter=p7)
                p8v = designPoint1.GetParameterValue(Parameter=p8)
                p9v = designPoint1.GetParameterValue(Parameter=p9)
                p10v = designPoint1.GetParameterValue(Parameter=p10)
                p11v = designPoint1.GetParameterValue(Parameter=p11)
                f= open ("result.txt","a")
                f.write("%s %s %s %s %s %s %s %s %s %s %s  \n \n" %(round(p1v.Value),p93v.Value,p3v.Value,p4v.Value,p5v.Value,p6v.Value,p7v.Value,p8v.Value,p9v.Value,p10v.Value,p11v.Value))
                f.close()
                Save(
                        FilePath="E:/2 Phase - all degree - 6 inch/%s [degree]---(%s).wbpj" %(round(p1v.Value),p2v),
                        Overwrite=True)
                       
               
               
                j=j+1
               
        p1v = p1v + dp1
        p1v=p1v.ConvertUnit("degree")
        p1v= str (p1v)
        designPoint1.SetParameterExpression(
                Parameter=p1,
                Expression=p1v)
        designPoint1.SetParameterExpression(
                Parameter=p2,
                Expression="100000")
               
        i=i+1
       
exit

It was better than using rsm. :)


All times are GMT -4. The time now is 14:27.