CFD Online Discussion Forums

CFD Online Discussion Forums (
-   CFX (
-   -   Piston-cylinder compression (

RLiddy May 2, 2013 06:44

Piston-cylinder compression
Hi everyone,

I am trying to model a two-stroke engine crankcase compression. I want to measure the air velocity and temperature at the top of the transfer ports for varying compression ratios. I am aiming to use workbench meshing and CFX to solve. This is my geometry as it stands:

The piston will be larger eventually, i was just trying to make it simpler until i figured the motion out.
I want the piston to move from its current position downwards to BDC. To do this i have put a specified displacement of -14.22*t on the piston. There are 100 timesteps each being 4.57E-05 s.

My problem is with my mesh. When I run the solver, it will run for 5-10 timesteps(mesh dependent) before I get the negative sector and element volume errors. Even with a super fine structured mesh I get these errors and weirdly it seems to run for longer on a coarser mesh... This is one of the meshes i tried:

I was until this point trying to get workbench remeshing to work, however, stumbled upon a thread that mentioned this motion can be done without remeshing.

Can anyone please give me a brief run down on how to set the mesh up and any expressions or conditions that I would need to complete the full cycle.
Thanks alot.



ghorrocks May 2, 2013 06:56

Yes, you should be able to do this without remeshing. You just need to put GGIs in the right spots. Make the side walls of the upper cylinder (above the piston) and crank case GGIs and let them slide up and down over the inlet/exhaust and transfer ports. You will need to make them transient rotor-stator interfaces for this to work.

Also you will need to adjust your geometry so the piston covers the entire cylinder cross section and the skirt is the right length to open and close the ports at the right timing.

RLiddy May 2, 2013 08:09

When you say "adjust your geometry so the piston covers the entire cylinder cross section" do you mean:
1. Say i have a cylinder bore of 87.1mm, make the piston 87mm diameter so there is a tiny thin wall left?

2. If theres the 87.1mm more, make the piston 87.1mm and essentially separate the upper cylinder, exhaust port and crankcase?

ghorrocks May 2, 2013 18:42

It depends on what you are trying to model. If you are trying to model blowby and piston sealing then use 1 (but you will need to include the piston rings). If you are ignoring blowby then use 2. For general engine modelling option 2 is the way to go. This means that when the ports are closed they do not connect to anything and just float in space.

RLiddy May 3, 2013 02:41

Not interested in blowby, so I changed my model to the first option:

Then i created a moderately fine structured mesh:

Now for my boundary conditions:

That pic shoes the ggi interfaces

Currently I have:
Exhaust - Defined as an opening with pressure as 0 stationary mesh motion
Intake - Defined as an inlet with a velocity of 2m/s. stationary mesh motion
Symmetry - Used to cut the model in half, unspecified mesh motion
Piston - Defined as a wall with a specified mesh displacement of -14.22*t
Then the two sides of the GGI interface.
When i have the GGI set as the following:

I get a floating point error: overflow. I have tried changing the turbulence model, number of timesteps and setting it to double precision. however it keeps happening at the same time(during the 5th timestep). I have 100 timesteps, they move the piston 0.65mm each step, is this too much?

My questions are:
1. What do i set for the pitch and below in the interface menu? (see pic above)
2. On each side of the interface the mesh motion by default is set to 'conservative interface flux'. Should this be unspecified or the same equation for the piston motion?
3. Since the exhaust port and the top ends of the transfer ports are floating now, do i need special conditions for them to stop an error?

Thanks heaps, Reece

ghorrocks May 3, 2013 03:05

You can't define the inlet as a 2m/s inlet. Where is the air going to go when the port is closed? It has to be a pressure opening.

You will need to put the proper motion on your piston. Use a sin function, or preferably derive the function for the crankshaft/conrod combination (it is not hard).

Your floating point error is because of your constant velocity inlet condition. You need to fix this - then you can move onto the next error :)

Pitch change = None.
The stationary side of the interface (ie the ports) does not need setting (it is stationary!). The cylinder side is to be set at unspecified.

I do not understand point 3.

RLiddy May 3, 2013 20:16

Point three reworded: as the exhaust port is now essentially floating in space, do i need to put any special constraints on it to avoid it creating an error?

I have changed everything and I am still getting the floating point error. I believe it is still coming from my intake boundary condition.

When I use a velocity intake it errors out with a floating point error
When I use a pressure intake, it creates a wall to avoid the backflow from leaving the crankcase and when the wall finally covers 100% of the intake it errors with the floating point.
When I use a pressure opening I still get a floating point error. I have varied the static pressure, opening pressure, set it to entrainment and have varied the turbulence to zero gradient as recommended by cfx-pre. I am working with a pressure of 0.2 MPA at the intake and a pressure of 0 Pa at the exhaust.

Didn't want to ask this one but looks like it has come to it... What am I doing wrong? lol

Thanks, Reece

ghorrocks May 5, 2013 07:58

It is best to make this model a 2 or a 3 domain model. 1 domain is the cylinder and contains all the moving mesh, and 1 domain contains the stationary bits and does not have a moving mesh model. Optionally, you can put the inlet and exhaust in different domains as this may have a slight convergence improvement due to reduced round off error.

So if the inlet and exhaust ports are stationary then you do not need to define anything for them in terms of moving mesh.

* I have already said you cannot use a velocity inlet.
* No, do not use an inlet, use an opening. You must allow backflow.
* Set the total pressure of the inlet. Forget the two options you mentioned previously and work on this one.

When the inlet and exhaust valve first crack open you get very high pressure drops over small port areas. This means a short squirt of supersonic flow until things have equalised a bit. This also means very difficult convergence. So use smaller time steps just as the valves crack open.

RLiddy May 7, 2013 00:24

Changed everything to your suggestions however I am still getting the floating point error:overflow error.
So I rebuilt my geometry without the piston skirts (so the air can flow straight in and out of the cylinder) and it made it through the run without error.
I then went and added the exhaust port skirt back in and straight away the error was back. I have the exhaust opening pressure to 1atm and the intake opening pressure to 1.1 atm. The relative domain pressure is 1atm and initialization pressure is 0. Those pressures did not change before and after the exhaust skirt being added in.
Cannot figure it out for the life of me...

ghorrocks May 7, 2013 00:34

Have you checked the mesh motion is behaving itself?

Do a simulation where you save a results file every time step with the mesh. Using expert parameters turn the fluids, thermal, turbulence and all other solvers off. Then run it and all it should do is move the mesh through its motion. Load it in the post processor and check the mesh is not doing silly things. Post some images of it when you have done this.

This is a the first thing to check. There are many more :)

RLiddy May 7, 2013 07:30

Well it turns out the mesh isnt behaving well. It continually errors out in the same spot around the 50/100 timestep mark. The point in the following photos are exactly where the solver said the negative element is.

It looks as if the mesh is being compressed under the piston skirt and stretched from the side of the cylinder which is causing it to stretch and fold. Still trying to find the right mesh to solve this.

ghorrocks May 7, 2013 19:39

This is the expected error - I have done zillions of engine models and have seen them all before :) (ps: you might be interested to see my PhD thesis:

Split the piston skirt into two regions. In the region inside the piston skirt use a mesh motion function which is constant everywhere - in other words the entire region moves as a solid block. In the region from the skirt to the bottom of the crankcase make it a simple square ended cylinder and then the mesh expansion/contraction will work fine.

RLiddy May 8, 2013 00:40

Ahh its always the simple solution that I don't think of lol

RLiddy May 8, 2013 22:13

Ok the mesh motion is running well now. Maximum skew i have is 0.5 and the aspect ratio stays below 10 so im happy with that. It needs to be refined but ill do that once its all working. This is what it looks like:

I then went and re-enabled all the solvers and tried a run, and once again on the second timestep i get the 'floating point error: overflow'
I changed the intake and exhaust pressures to try and prevent supersonic flow, Intake is 5KPa and exhaust is 0Pa.
Two questions now,
1. Should i leave the relative pressure of each domain (i have the three now) as 1atm or change?
2. What exactly does the GGI setting transient rotor stator do? When i ran the mesh deformation check it worked with it on and off... but with the fluid involved both setting error at the same time.

Anything else i should check over to try get rid of this damn error?


ghorrocks May 8, 2013 22:31

Good, now the mesh is working.

Now to get it converging. I would do a simple model with just the cylinder. So remove the inlet and exhaust port. Does that run? This has to be able to run before the full thing will run.

Once a cylinder only model works then put the inlet and exhaust back in and get the interfaces working.

RLiddy May 8, 2013 23:25

Remove the transfer ports too as they have an interface on them as well?
Where do i put the flow going from-->to? the upper and lower cylinder will now be completely separated.

ghorrocks May 8, 2013 23:34

Yes, remove the ports and interfaces. Just have a sealed blob of gas above and below the piston which you compress. This is a worthwhile validation check (against adiabatic compression curves) to check the accuracy of the model as well. Can do mesh and tiem step checks on this simple model much easier than the full thing.

RLiddy May 9, 2013 10:16

Finally worked out I was doing something monumentally stupid. Almost don't want to say it but, I was using Air at 25 degrees C which holds a constant density hence it cant compress........ When I changed it to air at ideal gas it made it through the run without error.

I do still have some errors with my interfaces though, the fluid doesn't go from the transfer ports into the upper cylinder and the intake was letting the air into the lower cylinder weirdly, so I'll have a go at fixing them in the morning.

ghorrocks May 9, 2013 18:06

I was starting to suspect that :)

But do not go to the full model yet. On this simple compression of a gas in a cylinder model use it to compare against analytical equations on isentropic gas compression. I think you will find it a VERY useful exercise in CFD accuracy.

RLiddy May 13, 2013 06:03

Dusted off the old Thermodynamics textbook over the weekend. I had to adjust the mesh, turbulence model and activate the double precision solver and I started to get some accurate results.

So I went and added in the ports, fiddled with the interfaces a little bit and tada! We have success!!!!!
(See video below)

All times are GMT -4. The time now is 18:15.