|
[Sponsors] |
Field Function syntax for density change by time |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 26, 2021, 14:56 |
Field Function syntax for density change by time
|
#1 |
New Member
Marcel
Join Date: Dec 2020
Location: Germany
Posts: 17
Rep Power: 5 |
Hello all,
i can not find the right syntax in StarCCM+ documentation for derivation after time. I want to create a field function which gives me the density chance by time: mathematically: d(density)/d(time) (The "grad" syntax provides me a gradient of a scalar, that is not what i want, because the derivation in the gradient function is after x,y,z) Thanks for your help |
|
May 27, 2021, 04:20 |
|
#2 |
Senior Member
|
I think you have to create a monitor and plot from the report. Report density and then plot it for solution progress. So the slope of this curve will be d(rho)/dt
|
|
May 27, 2021, 04:29 |
|
#3 |
New Member
Marcel
Join Date: Dec 2020
Location: Germany
Posts: 17
Rep Power: 5 |
Thank you for your reply.
With your solution i only can get the derivation of density by time at one specific point or at one average plane, but i would like to see d(rho)/dt in my whole model with a scalar scene. Like the velocity for example. Is there no syntax for d/dt for field functions? That would be the easiest way to solve the problem |
|
May 27, 2021, 11:07 |
|
#4 |
New Member
Marcel
Join Date: Dec 2020
Location: Germany
Posts: 17
Rep Power: 5 |
I have now tryed the following approach:
- I created a monitor called "DensityNow" (Time-Step-Frequency = 1 and Sliding Window =1) That monitor should determine the Density in the current time step. - I created a monitor called "DensityPrev" (Time-Step-Frequency = 1 and Sliding Window =2) That monitor should determine the Density in the time step before the current time step. - I created a monitor called "TimeNow" (Time-Step-Frequency = 1 and Sliding Window =1) That monitor should determine the physical time in the current time step. - I created a monitor called "TimePrev" (Time-Step-Frequency = 1 and Sliding Window =2) That monitor should determine the physical time in the time step before the current timestep. After that i created a field function called "DensityDeriv" which should calculate delta(density)/delta(time) because this is the best approximation for derivation i guess. Field function syntax: (DensityNow - DensityPrev) / (TimeNow - TimePrev) I havent worked yet with monitors, sliding windows and unsteady simulations in general, so i think there is a failure in my concept, because it doesnt work like i want I thought if i go to scalar scene now and choose my field function "DensityDeriv" i will see the derivation of the density (after the simulation did at least the second time step). But nothing happens at all in the scalar scene. Can someone give me feedback or does someone see a mistake in my concept? Thanks ! |
|
May 27, 2021, 16:02 |
|
#5 |
Senior Member
Joern Beilke
Join Date: Mar 2009
Location: Dresden
Posts: 523
Rep Power: 20 |
DensityNow = $Density
(TimeNow - TimePrev) = $TimeStep Just try this Java-Macro: setDensityDerivate.java: Code:
package macro; import star.common.*; import star.base.report.*; public class setDensityDerivate extends StarMacro { public void execute() { execute0(); } private void execute0() { Simulation sim_ = getActiveSimulation(); String nameFMM_Density = "densOld"; String nameFF_DensityDerivate = "DensityDerivate"; // Density from previous time step FieldMeanMonitor fMM_Density; if (sim_.getMonitorManager().has(nameFMM_Density)) { fMM_Density = (FieldMeanMonitor) sim_.getMonitorManager().getMonitor(nameFMM_Density); } else { fMM_Density = sim_.getMonitorManager().createMonitor(FieldMeanMonitor.class); fMM_Density.setPresentationName(nameFMM_Density); } fMM_Density.getParts().setObjects(sim_.getRegionManager().getRegions()); fMM_Density.setFieldFunction(sim_.getFieldFunctionManager().getFunction("Density")); fMM_Density.setSlidingWindow(true); fMM_Density.getSlidingWindowOption().setValue(2); // DensityDerivateFieldFunction UserFieldFunction userFF; if (sim_.getFieldFunctionManager().has(nameFF_DensityDerivate)) { userFF = (UserFieldFunction) sim_.getFieldFunctionManager().getFunction(nameFF_DensityDerivate); } else { userFF = sim_.getFieldFunctionManager().createFieldFunction(); userFF.setFunctionName("densityDerivate"); userFF.setPresentationName(nameFF_DensityDerivate); } userFF.getTypeOption().setSelected(FieldFunctionTypeOption.Type.SCALAR); userFF.setDefinition("($Density - $" + nameFMM_Density + "Monitor ) / $TimeStep"); } } I'm not sure if it gives the correct result. In previous versions a sliding window size of 1 worked. But it looks like the Monitor gets updated before the plotting, instead at the begin of the next time step. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
courant number increases to rather large values | 6863523 | OpenFOAM Running, Solving & CFD | 22 | July 6, 2023 00:48 |
[swak4Foam] swakExpression not writing to log | alexfells | OpenFOAM Community Contributions | 3 | March 16, 2020 19:19 |
pimpleDyMFoam computation randomly stops | babapeti | OpenFOAM Running, Solving & CFD | 5 | January 24, 2018 06:28 |
[mesh manipulation] Importing Multiple Meshes | thomasnwalshiii | OpenFOAM Meshing & Mesh Conversion | 18 | December 19, 2015 19:57 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |