CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   STAR-CCM+ (https://www.cfd-online.com/Forums/star-ccm/)
-   -   Java Macro -- Passive Pith in Superposing Rotation Motion (https://www.cfd-online.com/Forums/star-ccm/204878-java-macro-passive-pith-superposing-rotation-motion.html)

Weidong Dai August 3, 2018 08:41

Java Macro -- Passive Pith in Superposing Rotation Motion
 
3 Attachment(s)
Hi everyone,

I met a problem. There is a blade actively rotating in Y direction ('Rotation'), however it will passively rotate ('Pitch') in Z direction. ('Pitch' axis will change based on time). You can find the geometry in attached file.

The idea is using Rotation motion for 'Rotation'and Superposing Motion for 'Pitch' at the same time. Here is a java code to calculate 'Pitch' rotation rate but it does not work. But if I use it to change the rotation rate for 'Rotation', it works. So I think there might be something wrong when I try to read information for 'Pitch', '' SuperposingRotatingMotion rotation =(SuperposingRotatingMotion) sim. get(SuperposingMotionManager.class).getObject("Pit ch"); '' When I used it, it will show 'Manager is not found in ManagerManager'.

I just wonder if any of you meet similar problem or you know how to fix this. Thank you very much. :)

Cheers,
Weidong Dai



**************************************************
Code:

package macro;

import star.base.report.Report;
import star.common.ImplicitUnsteadySolver;
import star.common.PhysicalTimeStoppingCriterion;
import star.common.Simulation;
import star.common.StarMacro;
import star.motion.MotionManager;
import star.motion.RotatingMotion;
import star.motion.SuperposingMotionManager;
import star.motion.SuperposingRotatingMotion;

public class PitchRate extends StarMacro {

public void execute() {
Simulation sim = getActiveSimulation();

//RotatingMotion rotation = (RotatingMotion) sim.get(MotionManager.class).getObject("Rotation") ; // if I use this line, it will work and change the rotation rate for 'Rotation'

SuperposingRotatingMotion rotation =(SuperposingRotatingMotion) sim. get(SuperposingMotionManager.class).getObject("Pit ch"); // If I use this to change the 'Pitch' rate, it did not work.

Report torqueReport = sim.getReportManager().getReport("TorqueReport"); // torque report

PhysicalTimeStoppingCriterion maxTimeStoppingCriterion = (PhysicalTimeStoppingCriterion) sim.getSolverStoppingCriterionManager().getSolverS toppingCriterion("Maximum Physical Time");

double rotationRate = 0;
double timeStep = ((ImplicitUnsteadySolver) sim.getSolverManager().getSolver(ImplicitUnsteadyS olver.class)).getTimeStep().getValue();

do {
if(sim.getSolution().getPhysicalTime()>0) {
double currentTorque = torqueReport.getReportMonitorValue();
rotationRate = rotationRate+currentTorque/10000*timeStep;
rotation.getRotationRate().setValue(rotationRate);
}
sim.getSimulationIterator().step(1);

} while(!maxTimeStoppingCriterion.getIsSatisfied());
}
}
************************************************** ******

Weidong Dai August 3, 2018 08:43

Hi everyone

I forgot to say, the code is from abdul099. :)

https://www.cfd-online.com/Forums/st...-function.html.

Cheers~
Weidong Dai

Weidong Dai August 4, 2018 05:39

Hi guys

I figured out how to do it today. :cool: You need to claim 'rotation' first and say 'pitch' is a sub file of 'rotation' . The code should be like:


RotatingMotion rotation = (RotatingMotion) sim.get(MotionManager.class).getObject("Rotation") ;

SuperposingRotatingMotion pitch =(SuperposingRotatingMotion) rotation.getSuperposingMotionManager().getObject(" Pitch");


Hope you guys will think it is useful.

And now I am working on adding a torsional spring for the passive pitch, if you guys know how to deal with this, be free to leave comments.

Cheers
Weidong Dai


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