CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

Re JAVA MACROS

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By kamal tewari

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 10, 2016, 14:05
Default Re JAVA MACROS
  #1
Member
 
Polard
Join Date: Oct 2015
Posts: 31
Rep Power: 10
kamal tewari is on a distinguished road
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());




}
}
ramakant likes this.
kamal tewari is offline   Reply With Quote

Old   August 11, 2016, 09:59
Default
  #2
Member
 
Join Date: Nov 2015
Posts: 38
Rep Power: 10
Schwob77 is on a distinguished road
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.
Schwob77 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 10:48.