|
[Sponsors] |
August 10, 2016, 14:05 |
Re JAVA MACROS
|
#1 |
Member
Polard
Join Date: Oct 2015
Posts: 31
Rep Power: 10 |
Hi all
I am designing a adaptive controller which takes input from 2 reports(at two points in flow) and then apply the FIR algorithm in order to get minimum error to adapt for system changes. For this I need to write a java macro . I have written a macro for this as shown below but it is showing the message Run Time Error Plz help. package macro; import java.util.*; import star.common.*; import star.base.neo.*; import star.base.report.*; import star.common.ImplicitUnsteadySolver; import star.common.PhysicalTimeStoppingCriterion; public class Testing extends StarMacro { public void execute() { execute0(); } private void execute0() { Simulation simulation_0 = getActiveSimulation(); MaxReport maxReport_1 = ((MaxReport) simulation_0.getReportManager().getReport("Maximum 3")); // Reads data of error microphone to file MaxReport maxReport_2 = ((MaxReport) simulation_0.getReportManager().getReport("Maximum 1")); PhysicalTimeStoppingCriterion maxTimeStoppingCriterion = (PhysicalTimeStoppingCriterion) simulation_0.getSolverStoppingCriterionManager().g etSolverStoppingCriterion("Maximum Physical Time"); maxTimeStoppingCriterion.getMaximumTime().setValue (80.0); // Change maximum physical time here double X[]={0,0,0,0,0,0,0,0,0,0}; double err=0; double mu=0.01; double w[]={0,0,0,0,0,0,0,0,0,0}; double d[]={0,0,0,0,0,0,0,0,0,0}; double timeStep = ((ImplicitUnsteadySolver) simulation_0.getSolverManager().getSolver(Implicit UnsteadySolver.class)).getTimeStep().getValue(); do { if (simulation_0.getSolution().getPhysicalTime() > 0) // Change Solution time after which macro is to be executed { X=d; double currentNoise=maxReport_1.getReportMonitorValue(); double inputNoise=maxReport_2.getReportMonitorValue(); d[1]=inputNoise; double op1=currentNoise; double op2=0; for (int j=1;j<11;j++) { op2 = op2 + w[j]*d[j]; } err=op1-op2; for (int j=1;j<11;j++) { w[j] = w[j] + 2.0*mu*err*X[j]; } for(int j=10;j>1;j--) { d[j] = d[j-1]; } } simulation_0.getSimulationIterator().step(1); } while (!maxTimeStoppingCriterion.getIsSatisfied()); } } |
|
August 11, 2016, 09:59 |
|
#2 |
Member
Join Date: Nov 2015
Posts: 38
Rep Power: 10 |
Can you please post the error message that you get.
Did you make sure, that all reports have the correct input parts to deliver reasonable values? Do the reports have the correct Representation applied? Last edited by Schwob77; August 11, 2016 at 15:54. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Run Java macros in Star Ccm+ | peter parkour | STAR-CCM+ | 2 | November 6, 2015 02:48 |
Macro to access java files in sub-directory | abraum | STAR-CCM+ | 3 | July 11, 2012 02:46 |
Open simulation Java Macros | nico | Siemens | 2 | June 9, 2007 06:41 |
Getting OpenFOAM to coexist with an existing JAVA VM | nik777 | OpenFOAM Installation | 5 | February 22, 2007 07:21 |
What are UDF macros C_T_S , C_T_AP,...???? | Asghari | FLUENT | 0 | January 28, 2007 10:54 |