CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   STAR-CCM+ (https://www.cfd-online.com/Forums/star-ccm/)
-   -   Which Time Step - Implicit Unsteady (https://www.cfd-online.com/Forums/star-ccm/135872-time-step-implicit-unsteady.html)

mosef May 19, 2014 08:40

Which Time Step - Implicit Unsteady
 
Hi,
I'm simulating the melting and solidification of a spherical capsule (2D), which is filled with paraffin.
I'm using an Implicit unsteady model.
How can I find an appropriate time step? I have 30000 cells and currently my time step is 0,2s. I set the Courant number to 4. But which connection is between Courant Number and time step?
It is also possible to vary the time step?
The physical time to melt the paraffin is about 8000s. But whith this small time step, I need a few days for the simulation. I worry with a larger time step the simulation will not work.
Can you help me?
Thx a lot!

me3840 May 19, 2014 12:03

Your current timestep is already pretty high for VOF. You want the CFL on the VOF interface to be 1. You can track this variable if you want.

Push the Courant number higher and include fewer inner iterations to get a cheaper calculation.

You can put a field function in place of the timestep and dynamically change it based on CFL if you want.

mosef May 19, 2014 15:15

Ok thanks so far. I'll try this tomorrow!

mosef May 20, 2014 08:16

2 Attachment(s)
Do I understand that correctly, that the CFL-number ist NOT the same as the courant number?!
I want the CFL to be 1 on the interface, yes. But I don't understand how I can define something as variable if I set the number to f.e. 4?
And WHERE should I define that? The only input field for CFL numbers I can find is in physic models -> Segregated Flow / VOF
Attachment 31013

Attachment 31014

I can send you my .sim file if u want
thx

me3840 May 20, 2014 10:15

You cannot explicitly set the CFL using an implicit method. You will have to make a feedback system. Run iteration > check CFL > if too high, reduce time step > if too low, increase time step.

mosef May 20, 2014 10:27

Ok, I understand this.
I made a new report -> Maximum -> Skalar Field Function: Convective Courant Number.
The Courant Number is about 0,02.
I think it's too low, so I try to increase the time step, right?

me3840 May 20, 2014 10:53

That's correct.

mosef May 20, 2014 11:02

Ok thanks so far :)

mosef May 27, 2014 05:12

Can I make a field function that describes the relation between Time Step and Convective Courant Number?
I wanna make a function whith this statement:

"If the Courant Number is larger than 1, then the Time Step should be reduced by 0,01 seconds".

Is that possible?
I am not good at programming, so Can you help me with this problems if it is possible?
My Field Function so far is:
(${ConvectiveCourantNumber}<=1.0) ? (${TimeStep} -0.01)
But I think it's wrong...

me3840 May 28, 2014 10:00

Take a look at this macro I wrote to control the timestep dynamically. You have the idea right with your function, but to make it work well you need to be a little more sophisticated.

Code:




import java.util.*;

import star.common.*;
import star.base.neo.*;
import star.vis.*;
import star.base.report.*;
import star.flow.*;

public class timeStepControlByFF extends StarMacro {

    public void execute() {
        execute0();
    }

    private void execute0() {

        Simulation sim = getActiveSimulation();

        UserFieldFunction userFieldFunction_0 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_0.setPresentationName("userCalculatedTimeStep");
        userFieldFunction_0.setFunctionName("userCalculatedTimeStep");
        userFieldFunction_0.setDefinition("(($userTempTimeStep >= $userMaxDecrease)  && ($userTempTimeStep <= $userMaxIncrease)  && ($userTempTimeStep<$userMaxTimeStep) && ($userTempTimeStep>$userMinTimeStep))  ? $userTempTimeStep:$userLimitedTimeStep");

        UserFieldFunction userFieldFunction_1 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_1.setPresentationName("userDesiredCFL");
        userFieldFunction_1.setFunctionName("userDesiredCFL");
        userFieldFunction_1.setDefinition("20");

        UserFieldFunction userFieldFunction_2 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_2.setPresentationName("userLimitedTimeStep");
        userFieldFunction_2.setFunctionName("userLimitedTimeStep");
        userFieldFunction_2.setDefinition("$userDesiredCFL < $userMaxCFLReport ? ($userMaxDecrease>$userMinTimeStep ? $userMaxDecrease:$userMinTimeStep):($userMaxIncrease<$userMaxTimeStep ? $userMaxIncrease:$userMaxTimeStep)");

        UserFieldFunction userFieldFunction_3 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_3.setPresentationName("userMaxDecrease");
        userFieldFunction_3.setFunctionName("userMaxDecrease");
        userFieldFunction_3.setDefinition("0.5*$TimeStep");

        UserFieldFunction userFieldFunction_4 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_4.setPresentationName("userMaxIncrease");
        userFieldFunction_4.setFunctionName("userMaxIncrease");
        userFieldFunction_4.setDefinition("2.0*$TimeStep");

        UserFieldFunction userFieldFunction_5 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_5.setPresentationName("userMaxTimeStep");
        userFieldFunction_5.setFunctionName("userMaxTimeStep");
        userFieldFunction_5.setDefinition("0.025");

        UserFieldFunction userFieldFunction_6 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_6.setPresentationName("userMinTimeStep");
        userFieldFunction_6.setFunctionName("userMinTimeStep");
        userFieldFunction_6.setDefinition("0.0001");

        UserFieldFunction userFieldFunction_7 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_7.setPresentationName("userTempTimeStep");
        userFieldFunction_7.setFunctionName("userTempTimeStep");
        userFieldFunction_7.setDefinition("$userDesiredCFL*$TimeStep/$userMaxCFLReport");

        UserFieldFunction userFieldFunction_8 = sim.getFieldFunctionManager().createFieldFunction();
        userFieldFunction_8.setPresentationName("userTimeStepControl");
        userFieldFunction_8.setFunctionName("userTimeStepControl");
        userFieldFunction_8.setDefinition("$Time==0 ? $userMinTimeStep:$userCalculatedTimeStep");

        ImplicitUnsteadySolver implicitUnsteadySolver_0 = ((ImplicitUnsteadySolver) sim.getSolverManager().getSolver(ImplicitUnsteadySolver.class));

        implicitUnsteadySolver_0.getTimeStep().setDefinition("$userTimeStepControl");

        Units units_1 = ((Units) sim.getUnitsManager().getObject("m"));

        NullFieldFunction nullFieldFunction_0 = ((NullFieldFunction) sim.getFieldFunctionManager().getFunction("NullFieldFunction"));
        ThresholdPart thresholdPart_1 = sim.getPartManager().createThresholdPart(new NeoObjectVector(new Object[]{}), new DoubleVector(new double[]{0.0, 1.0}), units_1, nullFieldFunction_0, 0);
        thresholdPart_1.setPresentationName("userTimeStepControlThreshold");
        thresholdPart_1.getRangeQuantities().setArray(new DoubleVector(new double[]{0.45, 0.55}));

        MaxReport maxReport_1 = sim.getReportManager().createReport(MaxReport.class);
        maxReport_1.setPresentationName("userMaxCFL");
        CourantNumberFunction courantNumberFunction_0 = ((CourantNumberFunction) sim.getFieldFunctionManager().getFunction("CourantNumber"));
        maxReport_1.setScalar(courantNumberFunction_0);
        maxReport_1.getParts().setObjects(thresholdPart_1);

        MaxReport maxReport_0 = sim.getReportManager().createReport(MaxReport.class);
        maxReport_0.setPresentationName("userTimeStep");
        PrimitiveFieldFunction primitiveFieldFunction_0 = ((PrimitiveFieldFunction) sim.getFieldFunctionManager().getFunction("TimeStep"));
        maxReport_0.setScalar(primitiveFieldFunction_0);
        sim.getMonitorManager().createMonitorAndPlot(new NeoObjectVector(new Object[]{maxReport_0}), true, "%1$s Plot");
        ReportMonitor reportMonitor_0 =((ReportMonitor) sim.getMonitorManager().getMonitor("userTimeStep Monitor"));
        MonitorPlot monitorPlot_0 =sim.getPlotManager().createMonitorPlot(new NeoObjectVector(new Object[]{reportMonitor_0}), "userTimeStep Monitor Plot");
       
        sim.println("\n");
        sim.println("userTimeStepControl setup complete");
        sim.println("==============================================");
        sim.println("WARNING: Set the threshold userTimeStepControlThreshold's region and field function assignment before iterating!");
        sim.println("WARNING: Set the report userTimeStep's region assignment before iterating!");
        sim.println("==============================================");
    }
}



All times are GMT -4. The time now is 23:37.