Sandwich.java

Sandwich.java — Java source code, 25 kB (25.882 bytes)

Dateiinhalt

import java.applet.Applet;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Date;
import java.util.Locale;
import java.util.Vector;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.KeyStroke;

import optimization.*;

/**
 * 
 * @author K�ster
 *
 */
public class Sandwich extends Applet implements Fzero_methods, ActionListener{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4511007745422279777L;
	//double tf;
	//static double ts; //Laufvariable;
	//double b ;
	static double hs;
	static double h_min = 1;
	static double h_max = 40;
	static double E_haut = 70000;
	static double E_kern;
	static double G_kern;
	static double F = 5000;
	static double tau_zul = 180;
	static double sig_zul = 250;
	static double t_max = 30;
	static double t_min = 1;
	static double M = 5000;
	static double Q = 180;
	static double kappa;
	static double EI_soll;
	
	static double rho_haut = 2.7; // g/cm� Dichte
	static double rho_kern;
	static double G = 95;  //Startwert Gewicht
	
	//Fzero-Werte
	static double b[] = new double[2];  // = {0, 12};
	static double c[] = new double[2];  // = {0, 18};
	static int iflag [] = {0, 1};
	
	static String str_f_n;
	static String str_f_mm;
	
	static Graph gr = new Graph(t_min, t_max, h_min, h_max);
	static JFrame frame = new JFrame();
	
	static JTextField val_t_min = new JTextField("0");
	static JTextField val_t_max = new JTextField("30");
	static JTextField val_h_min = new JTextField("0");
	static JTextField val_h_max = new JTextField("40");
	static JTextField val_F = new JTextField("50");
	static JTextField val_M = new JTextField("5000");
	static JTextField val_Q = new JTextField("180");
	static JTextField val_E_haut = new JTextField("70000");
	static JTextField val_E_kern = new JTextField("100");
	static JTextField val_G_kern = new JTextField("35");
	static JTextField val_sig_zul = new JTextField("250");
	static JTextField val_tau_zul = new JTextField("180");
	static JTextField val_dens_haut = new JTextField("2.7");
	static JTextField val_dens_kern = new JTextField("0.1");
	static JTextField val_EI_soll = new JTextField("2000000");
	//static JTextField val_G = new JTextField("100");
	static JTextField val_t_start = new JTextField("30");
	static JTextField val_h_start = new JTextField("40");
	static JTextField val_kappa = new JTextField("0.33");
	final JTextArea erg_box = new JTextArea(7,10);
	final GridBagLayout gbl = new GridBagLayout();
	final GridBagConstraints gbc = new GridBagConstraints();
	static int rb_crink = 0;
	static String[] textstrings;
	static boolean EI_cb = false;
	JCheckBoxMenuItem cb_EI = new JCheckBoxMenuItem("EI enabled");
	boolean started_as_applet = true;
	
	public static void main (String [] args){
		Sandwich sw = new Sandwich();
		sw.started_as_applet = false;
		sw.init();
	}
	public void init(){
		Date zeit_start = new Date();
		
		//Oberfl�che:
		
		val_E_haut.setEnabled(false);
		val_E_kern.setEnabled(false);
		val_G_kern.setEnabled(false);
		val_kappa.setEnabled(false);
		val_E_haut.setEditable(false);
		val_E_kern.setEditable(false);
		val_G_kern.setEditable(false);
		val_kappa.setEditable(false);
		
		val_EI_soll.setEnabled(false);
		val_EI_soll.setEditable(false);
		
		frame.setLayout(gbl);
		
		JLabel lab_t_min = new JLabel("t min (mm): ");
		JLabel lab_t_max = new JLabel("t max (mm): ");
		JLabel lab_h_min = new JLabel("h min (mm): ");
		JLabel lab_h_max = new JLabel("h max (mm): ");
		JLabel lab_F = new JLabel("F (N/mm): ");
		JLabel lab_M = new JLabel("M (N�mm/mm): ");
		JLabel lab_Q = new JLabel("Q (N/mm): ");
		JLabel lab_E_haut = new JLabel("E-Modulus skin (N/mm): ");
		JLabel lab_E_kern = new JLabel("E-Modulus core (N/mm): ");
		JLabel lab_G_kern = new JLabel("G-Modulus core (N/mm): ");
		JLabel lab_sig_zul = new JLabel("sigma skin max (N/mm�): ");
		JLabel lab_tau_zul = new JLabel("tau core max (N/mm�): ");
		JLabel lab_dens_haut = new JLabel("density skin (g/cm�): ");
		JLabel lab_dens_kern = new JLabel("density core (g/cm�): ");
		//JLabel lab_G = new JLabel("max weight: ");
		JLabel lab_t_start = new JLabel("t start (mm): ");
		JLabel lab_h_start = new JLabel("h start (mm): ");
		JLabel lab_kappa = new JLabel("kappa: ");
		JLabel lab_EI_soll = new JLabel("EI min (N�mm�/mm): ");
		
		final JLabel lab_opt_text = new JLabel("Results of Optimization: ");
	
		final JScrollPane erg_scroll = new JScrollPane(erg_box);
		
		JButton but_calc = new JButton ("Calculate");
		but_calc.addActionListener(this);
		
		//Men�:
		JMenuBar meba = new JMenuBar();
			JMenu m_crinkle = new JMenu("Wrinkling Criteria");
				m_crinkle.setMnemonic('w');
				meba.add(m_crinkle);
				JRadioButtonMenuItem m_cr_none = new JRadioButtonMenuItem("none");
				m_cr_none.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,Event.CTRL_MASK));
				m_cr_none.setSelected(true);
				m_cr_none.addActionListener(this);
				m_crinkle.add(m_cr_none);
				JRadioButtonMenuItem m_cr_iso = new JRadioButtonMenuItem("isotropic material (foam)");
				m_cr_iso.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I,Event.CTRL_MASK));
				m_cr_iso.addActionListener(this);
				m_crinkle.add(m_cr_iso);
				JRadioButtonMenuItem m_cr_ortho = new JRadioButtonMenuItem("orthotropic material (honeycomb)");
				m_cr_ortho.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,Event.CTRL_MASK));
				m_cr_ortho.addActionListener(this);
				m_crinkle.add(m_cr_ortho);
				ButtonGroup rb = new ButtonGroup();
				rb.add(m_cr_none);
				rb.add(m_cr_iso);
				rb.add(m_cr_ortho);
			JMenu m_EI = new JMenu("EI min Criteria");
				m_EI.setMnemonic('e');
				meba.add(m_EI);
				cb_EI.addActionListener(this);
				m_EI.add(cb_EI);
				cb_EI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,Event.CTRL_MASK));
				
		frame.setJMenuBar(meba);
				
		//Layout:
		gbc.gridy = 0;
		gbc.gridheight = 1;
		gbc.gridwidth = 4;
		gbc.ipady = 8;
		gbc.weightx = 0;
		gbc.weighty = 0;
		//gbc.anchor = GridBagConstraints.NORTH;
		
		gbc.fill = GridBagConstraints.BOTH;
		JLabel label;
		/*if (!started_as_applet) label = new JLabel(new ImageIcon("Image4.PNG"));
		else {*/
			URL imgURL = getClass().getResource("Image4.PNG");
			new ImageIcon(imgURL);
			//System.out.println("started as applet");
			//String str = getCodeBase().getFile()+"Image3.PNG";
			//str = str.substring(1, str.lastIndexOf("/"));
			//str = str.substring(0, str.lastIndexOf("/")+1)+"Image3.PNG";
			//System.out.println(str);
			label = new JLabel(new ImageIcon(imgURL));
			//}
		
		gbl.addLayoutComponent(label, gbc);
		
		gbc.gridwidth = 1;
		
		gbc.insets = new Insets(0,10,0,0);
		gbc.gridy = 1;
		gbc.gridx = 0;
		gbl.addLayoutComponent(lab_F, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_M, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_Q, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_sig_zul, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_tau_zul, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_E_haut, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_E_kern, gbc);
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_G_kern, gbc); 
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_kappa, gbc);	
		
		gbc.insets = new Insets(0,20,0,0);
		gbc.gridy = 1;
		gbc.gridx = 2;
		gbl.addLayoutComponent(lab_t_min, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_t_max, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_h_min, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_h_max, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_dens_haut, gbc);
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_dens_kern, gbc);
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_EI_soll, gbc);
		gbc.gridy ++;
		//gbl.addLayoutComponent(lab_G, gbc);		
		gbl.addLayoutComponent(lab_t_start, gbc);
		gbc.gridy ++;
		gbl.addLayoutComponent(lab_h_start, gbc);		
		
		gbc.insets = new Insets(0,10,0,10);
		gbc.gridy = 1;
		gbc.gridx = 1;
		//gbc.weightx = 0;
		gbc.ipadx = 50;
		gbl.addLayoutComponent(val_F, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(val_M, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(val_Q, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(val_sig_zul, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(val_tau_zul, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(val_E_haut, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(val_E_kern, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(val_G_kern, gbc);	
		gbc.gridy ++;
		gbl.addLayoutComponent(val_kappa, gbc);	
		
		gbc.gridy = 1;
		gbc.gridx = 3;
		gbl.addLayoutComponent(val_t_min, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(val_t_max, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(val_h_min, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(val_h_max, gbc);		
		gbc.gridy ++;
		gbl.addLayoutComponent(val_dens_haut, gbc);
		gbc.gridy ++;
		gbl.addLayoutComponent(val_dens_kern, gbc);
		gbc.gridy ++;
		gbl.addLayoutComponent(val_EI_soll, gbc);
		gbc.gridy ++;
		//gbl.addLayoutComponent(val_G, gbc);
		gbl.addLayoutComponent(val_t_start, gbc);
		gbc.gridy ++;
		gbl.addLayoutComponent(val_h_start, gbc);
		
		gbc.gridx = 3;
		gbc.gridy += 1; //= 10;
		gbc.gridwidth = 1;
		gbc.ipadx = 0;
		gbc.insets = new Insets(0,10,0,10);
		gbl.addLayoutComponent(but_calc, gbc);
		
		//Ergebnisse:
		gbc.gridx = 0;
		gbc.gridy++; // = 10;
		gbc.weightx = 0;
		gbc.weighty = 0;
		gbc.gridwidth = 2;
		gbc.insets = new Insets(0,10,0,10);
		gbl.addLayoutComponent(lab_opt_text, gbc);
		/*
		gbc.gridy++;
		gbc.gridwidth = 1;
		gbc.anchor = GridBagConstraints.LINE_END;
		gbl.addLayoutComponent(lab_erg_t, gbc);
		gbc.gridy++;
		gbl.addLayoutComponent(lab_erg_h, gbc);
		*/
		
		gbc.gridx = 0;
		gbc.gridy++; // = 11;
		gbc.gridwidth = 4;
		gbc.weighty = 1;
		gbc.insets = new Insets(0,10,10,10);
		gbl.addLayoutComponent(erg_scroll, gbc);
		/*gbl.addLayoutComponent(erg_t, gbc);
		gbc.gridy++;
		gbl.addLayoutComponent(erg_h, gbc);*/
		
		gbc.gridx = 5;
		//gbc.gridy = 20;
		//gbc.weighty = 1;
		gbc.weightx = 1;
		JLabel spacekeeper = new JLabel();
		gbl.addLayoutComponent(spacekeeper, gbc);
		
		
		//Grafik in Frame einbinden:
		/*
		gbc.gridy = 20;
		gbc.weighty = 1;
		gbc.gridwidth = 10;
		gbl.addLayoutComponent(Graph.frame.getComponent(0), gbc);
		*/

		frame.add(label);
		frame.add(lab_t_min);
		frame.add(lab_t_max);
		frame.add(lab_h_min);
		frame.add(lab_h_max);
		frame.add(lab_F);
		frame.add(lab_M);
		frame.add(lab_Q);
		frame.add(lab_E_haut);
		frame.add(lab_E_kern);
		frame.add(lab_sig_zul);
		frame.add(lab_tau_zul);
		frame.add(lab_dens_haut);
		frame.add(lab_dens_kern);
		//frame.add(lab_G);
		frame.add(lab_t_start);
		frame.add(lab_h_start);
		frame.add(lab_G_kern);
		frame.add(lab_kappa);
		frame.add(lab_EI_soll);
		
		frame.add(val_t_min);
		frame.add(val_t_max);
		frame.add(val_h_min);
		frame.add(val_h_max);
		frame.add(val_F);
		frame.add(val_M);
		frame.add(val_Q);
		frame.add(val_E_haut);
		frame.add(val_E_kern);
		frame.add(val_sig_zul);
		frame.add(val_tau_zul);
		frame.add(val_dens_haut);
		frame.add(val_dens_kern);
		//frame.add(val_G);
		frame.add(val_t_start);
		frame.add(val_h_start);
		frame.add(val_G_kern);
		frame.add(val_kappa);
		frame.add(val_EI_soll);
		
		frame.add(but_calc);
		
		frame.add(lab_opt_text);
		//frame.add(lab_erg_t);
		//frame.add(lab_erg_h);
		/*frame.add(erg_t);
		frame.add(erg_h);*/
		frame.add(erg_scroll);
		
		frame.add(spacekeeper);
		
		//frame.add(Graph.frame.getComponent(0));
		
		//Graph.frame.setBackground(Color.WHITE);
		//frame.setBackground(Color.WHITE);
		
		
		frame.setSize(1000, 700);
		frame.setMinimumSize(new Dimension(480,460));
		frame.setLocationRelativeTo(null);
		frame.setTitle("Sandwich");
		/*if (!started_as_applet)*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
		
		
		
				//Schnittpunktbestimmung:
				/*
				System.out.println("\n f_n: " + f_n(b[1]));
				System.out.println("f_mm: " + f_mm(b[1]));
				*/
				/*
				String str_f_n = String.valueOf(f_n(b[1]));
				String str_f_mm = String.valueOf(f_mm(b[1]));
				str_f_n = str_f_n.substring(0, str_f_n.length()-1);
				str_f_mm = str_f_mm.substring(0, str_f_mm.length()-1);
				System.out.println("f_n: " + str_f_n);
				System.out.println("f_mm: " + str_f_mm);
				
				if (str_f_n.contains(str_f_mm) || str_f_mm.contains(str_f_n))
					System.out.println("Schnittpunkt vorhanden!");
				else
					System.out.println("Kein Schnittpunkt!");
		*/
		
				
		/*		
		gr = new Graph(t_min, t_max, h_min, 30, point);
		gr.draw();
		*/
				
		//double xmin = Fmin.fmin(-10,10,new j_bsp1_test(), 3.0e-8);
		
		//System.out.println("Min: " + xmin);
		
		Date zeit_ende = new Date();
		System.out.println("Laufzeit f�r Programmaufbau: " + (zeit_ende.getTime()-zeit_start.getTime()));
	}
	
	/**
	 * 
	 * @return Erg, if existing, else null
	 */
	public static Erg berechnenDurchGradient(){
		
		double meps = 2.23E-10; // 2.23E-16;
		
		//Steigung der Anzun�hernden linearen Funktion:
		double m_lin = f_n(2)-f_n(1);
		//System.out.println("Steigung der Geraden: " + m_lin);
		
		// Berechnung der Steigungen der Minimafunktion
		// Abgleichen mit m_lin durch Vergleich bis zur ?-ten Nachkommastelle
		
		double steig;
		double dx = 0.00001;
		
		//dx �nderung:
		if (rb_crink == 2) dx = 0.1; //-> H�here Rechengeschwinigkeit
		
		//Startsteigung:
		double last_steig = (f_mm(t_min+meps)-f_mm(t_min-meps))/(2.*meps);;
		
		Vector<Double> points = new Vector<Double>(); 
		double h = -1;
		double t = -1;
		
		for (double x = t_min+dx; x <= t_max; x += dx){  
			//Steigung berechnen:
			steig = (f_mm(x+meps)-f_mm(x-meps))/(2.*meps);
			
			//Auswertung der Steigungswerte:
			if ((steig > m_lin && last_steig < m_lin) || (steig < m_lin && last_steig > m_lin)){
			/*	System.out.println("Possible solution at x = " + x +
								"\n s_a: " + last_steig+
								"\n s_b: " + steig);
				//points.add(x); points.add(f_mm(x));
				System.out.println("x: " + x);
				System.out.println("f_mm(x): " + f_mm(x));
			*/	if (f_n(x) < f_mm(x)){
				//	System.out.println("Dies ist keine L�sung!\n");
				}else{
				//	System.out.println("Dies ist eine L�sung!\n");
					t = x;
					h = f_mm(x);
				}
				
			}
			last_steig = steig;
		}
		
		//Genauigkeit verbessern:
		dx = 0.000001;
		double r = 0.0001;
		if (rb_crink == 2) {dx = 0.0001; r = 0.2;}
		if (rb_crink == 0) {dx = 0.000001; r = 0.00002;}
		
		for (double x = t-r; x <= t+r; x += dx){  
			//Steigung berechnen:
			steig = (f_mm(x+meps)-f_mm(x-meps))/(2.*meps);
			
			//Auswertung der Steigungswerte:
			if ((steig > m_lin && last_steig < m_lin) || (steig < m_lin && last_steig > m_lin)){
			/*	System.out.println("Possible solution at x = " + x +
								"\n s_a: " + last_steig+
								"\n s_b: " + steig);
				
				System.out.println("x: " + x);
				System.out.println("f_mm(x): " + f_mm(x));
			*/	if (f_n(x) < f_mm(x)){
				//System.out.println("Dies ist keine L�sung!\n");
				}else{
				//System.out.println("Dies ist eine L�sung!\n");
					//points.add(x); points.add(f_mm(x));
					t = x;
					h = f_mm(x);
				}
				
			}
			last_steig = steig;
		}
		
		points.add(t); points.add(h);
		
		//Visualisierung:
		new Graph(t_min, t_max, h_min, h_max);
		gr.setPoints(points);
		gr.draw();
		
		if (h == -1)  return null;
		
		G = (t*2*rho_haut + h*rho_kern);
	/*	System.out.println("t: " + t);
		System.out.println("h: " + h);
		System.out.println("rho_haut: " + rho_haut);
		System.out.println("rho_kern: " + rho_kern);
	*/	//TODO
		double sig = Math.abs(F)/(2*t)+Math.abs(M)/(h*t);
		double tau = Q/h;
		
		return new Erg(t,h,G,sig,tau);
	}
	
	
	static Fzero_methods zero = new Sandwich();
	static Fzero_methods zero2 = new zero2kl();
	static boolean h_isZug;
	/**
	 * Enth�lt die Minimafunktionen und
	 * gibt das Maximum der Minimafunktionen an der Stelle x aus.
	 * @param x - Koordinate 
	 * @return Maximum der Minimafunktionen
	 */
	public static double f_mm(double t){
		double h, hvgl;
		
		//Minimalbedingungen:
		//f = M/x*1./(sig_zul-F/(2*x));
		
		//1.
		h = Math.abs(M)/t*1./(sig_zul-Math.abs(F)/(2*t));
		
		//2.
		if (rb_crink == 2){ //orthotropes Material
			//t an Zerofunktionen �bergeben
			now_t = t;
			
			//FH1:
			double h1;
			double[] max = {0,h_max};
			double[] min = {0,h_min};
			Fzero.fzero(zero, min ,max, (min[1]+max[1])/2.,0,0,new int[]{0,1});
			h1 = max[1];
			//System.out.println("h1: " + h1);
			//FH2:
			double h2;
			//double[] max = {0,h_max};
			//double[] min = {0,h_min};
			
			Fzero.fzero(zero2, min ,max, (min[1]+max[1])/2.,0,0,new int[]{0,1});
			h2 = min[1];
			//if (h2 = NaN)
			
			//h:
			hvgl = Math.max(h1, h2);
			
			if (String.valueOf(h2).equals("NaN")) hvgl = h1;
			//System.out.println("h2: " + h2);
			//System.out.println(String.valueOf(h2).equals("NaN"));
			if (String.valueOf(h1).equals("NaN")) hvgl = h2;
			
			if (h < hvgl) h = hvgl;
		}
	
		/*
		double h_neg = M/t*1./(sig_zul-F/(2*t));
		if (h_zug >= h_neg){
			h = h_zug; h_isZug = true;}
		else{
			h = h_neg; h_isZug = false;}
		*/
		/*
		double h_druck;
		if (rb_crink == 2){
				now_t = t;
				double[] max = {0,h_max};
				double[] min = {0,h_min};
				Fzero.fzero(zero, min ,max, (min[1]+max[1])/2.,0,0,new int[]{0,1});
				h_druck = max[1];
			if (F/(2*t)+M/(h*t) < 0 && h_druck > h_zug){
				h = h_druck; h_isZug = false;
			}
		}
		*/
		//System.out.println("h: " + h);
		
		//3.
		hvgl = h_min;
			if (h < hvgl) h = hvgl;
			
		//4.
		hvgl = Q/tau_zul;
			if (h < hvgl) h = hvgl;
		
		//5.
		if (EI_cb){
			hvgl = Math.sqrt(EI_soll * 2. / (E_haut * t));
			if (h < hvgl) h = hvgl;
		}
		
		return h;
	}
	
	/**
	 * Gibt den Funktionswert der anzun�hernden Funktion aus.<br>
	 * Die Funktion muss f�r das Gradientenverfahren linear sein
	 * 
	 * @param t - Koordinate
	 */
	public static double f_n(double t){
		double h = (G - 2*t*rho_haut)/rho_kern;
		return h;
	}
	
	static double now_t;
	public double f_to_zero(double h) {
		double f; 
		
		f = -kappa*Math.sqrt(E_haut*now_t*E_kern/h)+M/(h*now_t)+F/(2.*now_t); 
		
		//System.out.println("\nh: " + h);
		//System.out.println("f: " + f);
		
		return f;		
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		String cmd = e.getActionCommand();
	
		if (cmd.equals("none")){
			rb_crink = 0;
			val_E_haut.setEnabled(false);
			val_E_kern.setEnabled(false);
			val_G_kern.setEnabled(false);
			val_kappa.setEnabled(false);
			val_E_haut.setEditable(false);
			val_E_kern.setEditable(false);
			val_G_kern.setEditable(false);
			val_kappa.setEditable(false);
			System.out.println("RB: none");
		}
		else if (cmd.equals("isotropic material (foam)")){
			rb_crink = 1;
			val_E_haut.setEnabled(true);
			val_E_kern.setEnabled(true);
			val_G_kern.setEnabled(true);
			val_kappa.setEnabled(true);
			val_E_haut.setEditable(true);
			val_E_kern.setEditable(true);
			val_G_kern.setEditable(true);
			val_kappa.setEditable(true);
			System.out.println("RB: iso");
		}
		else if (cmd.equals("orthotropic material (honeycomb)")){
			rb_crink = 2;
			val_E_haut.setEnabled(true);
			val_E_kern.setEnabled(true);
			val_G_kern.setEnabled(false);
			val_kappa.setEnabled(true);
			val_E_haut.setEditable(true);
			val_E_kern.setEditable(true);
			val_G_kern.setEditable(false);
			val_kappa.setEditable(true);
			System.out.println("RB: ortho");
		}
		else if (cmd.equals("EI enabled")){
			EI_cb = cb_EI.isSelected();
			val_EI_soll.setEnabled(cb_EI.isSelected());
			val_EI_soll.setEditable(cb_EI.isSelected());
		}
		else if (cmd.equals("Calculate")){
			Date zeit_start = new Date();
			//R�cksetzen:
			try {Graph.frame.dispose();}catch(Exception ex){};
			erg_box.selectAll();
			erg_box.replaceSelection("");
			
			//Einlesen der Werte:
			try{
			t_min = Double.parseDouble(val_t_min.getText());
			t_max = Double.parseDouble(val_t_max.getText());
			h_min = Double.parseDouble(val_h_min.getText());
			h_max = Double.parseDouble(val_h_max.getText());
			F = Double.parseDouble(val_F.getText());
			E_haut = Double.parseDouble(val_E_haut.getText());
			E_kern = Double.parseDouble(val_E_kern.getText());
			G_kern = Double.parseDouble(val_G_kern.getText());
			Q = Double.parseDouble(val_Q.getText());
			//G = Double.parseDouble(val_G.getText());
			M = Double.parseDouble(val_M.getText());
			sig_zul = Double.parseDouble(val_sig_zul.getText());
			tau_zul = Double.parseDouble(val_tau_zul.getText());
			rho_haut = Double.parseDouble(val_dens_haut.getText())/*/(10*10*10)*/;
			rho_kern = Double.parseDouble(val_dens_kern.getText())/*/(10*10*10)*/;
			kappa = Double.parseDouble(val_kappa.getText());
			G = Double.parseDouble(val_t_start.getText()) * rho_haut * 2 +
				Double.parseDouble(val_h_start.getText()) * rho_kern ;
			EI_soll = Double.parseDouble(val_EI_soll.getText());
			
			//Knittern:
			double sig_zul_zug;
			
			if (rb_crink == 1){
				sig_zul_zug = kappa * Math.pow(E_haut*E_kern*G_kern, 1./3.);		
				if (sig_zul_zug < sig_zul) sig_zul = sig_zul_zug;
			}
					
			}catch(Exception exc){}
			
			//Berechnungsroutinen:
			//berechnenDurchAnnaeherung();
			Erg erg = berechnenDurchGradient();
			
			
			DecimalFormatSymbols locsym  = new DecimalFormatSymbols(Locale.ENGLISH);
			DecimalFormat df = new DecimalFormat( "0.000", locsym);
			DecimalFormat df2 = new DecimalFormat( "0.0", locsym);
			DecimalFormat df3 = new DecimalFormat( "#,###,###,##0", locsym);
			//erg_t.setText(String.valueOf(erg!=null ? " t = " + df.format(erg.t) : "No Solution found!"));
			//erg_h.setText(String.valueOf(erg!=null ? " h = " + df.format(erg.h) : "Parameters are norrowed down too much!"));
			erg_box.append(String.valueOf(erg!=null ? " t = " + df.format(erg.t) + " mm": "No Solution found!"));
			erg_box.append(String.valueOf(erg!=null ? "\n h = " + df.format(erg.h) + " mm": "\nParameters norrowed down too much!"));
			
			if (erg!=null){
				
				double FH1 = (F/2. + M/erg.h);
				double FH2 = (F/2. - M/erg.h);
				h_isZug = true;
				if (FH1 >= 0 && FH2 >= 0) h_isZug = true;
				else if (FH1 < 0 && FH2 < 0) h_isZug = false;
				else if (Math.abs(FH1) > Math.abs(FH2) && FH1 < 0) h_isZug = false;
				else if (Math.abs(FH2) > Math.abs(FH1) && FH2 < 0) h_isZug = false;
				double sig_crit = 0;
				if (rb_crink == 1) sig_crit = kappa*Math.pow(E_haut*E_kern*G_kern, 1./3.);
				else if (rb_crink == 2) sig_crit = kappa * Math.sqrt(E_haut*erg.t*E_kern/erg.h);
				
				erg_box.append("\n Weight = " + df.format(erg.G) + " kg/m�");
				erg_box.append("\n sigma skin max. = " + df2.format(sig_zul) + " N/mm�");
				if (rb_crink != 0) erg_box.append("\n sigma crit.= " + df2.format(sig_crit) + " N/mm�");
				erg_box.append("\n sigma = " + df2.format(erg.sigma) + " N/mm�");
				erg_box.append("\n tau = " + df2.format(erg.tau) + " N/mm�");
				erg_box.append("\n EI = " + df3.format(E_haut*erg.t*erg.h*erg.h/2.) + " N�mm�/mm");
				erg_box.append("\n FH1 = " + df.format(FH1) + "");
				erg_box.append("\n FH2 = " + df.format(FH2) + "");
				erg_box.append(h_isZug?"\n determining factor: tension":"\n determining factor: compression");
				
				if (erg.h > h_max || erg.t > t_max || erg.tau > tau_zul ||
					erg.sigma > sig_zul)
					erg_box.append("\n\nSome limits may have been exceeded!\nRaise some of them to get a solution!");
				
				if (textstrings != null)
					for (String str: textstrings)
						erg_box.append("\n" + str);
	
			}
			
			//Grafik Hinzuf�gen:
			/*
			gbc.gridx = 0;
			gbc.gridy = 20;
			gbc.weighty = 1;
			gbc.gridwidth = 10;
			 */
			//gbc.gridx = 20;
			gbc.gridy = 1;
			gbc.weighty = 1;
			gbc.weightx = 100;
			gbc.gridwidth = 10;
			gbc.gridheight = 15;
			
			gbc.insets = new Insets(0,0,0,0);
			//Grafik in Frame anzeigen (wahlweise /*mit Men�leiste*/):
			gbl.addLayoutComponent(Graph.fr/*ame.getComponent(0)*/, gbc);
						 frame.add(Graph.fr/*ame.getComponent(0)*/);	
			
			//frame.setSize(frame.getWidth(), 800);
			//frame.setLocationRelativeTo(null);
			frame.validate();
			
			Date zeit_ende = new Date();
			System.out.println("Laufzeit f�r Berechnung und Ausgabe: " + (zeit_ende.getTime()-zeit_start.getTime()));
		}
	}
}

class Erg{
	double t;
	double h;
	double G;
	double sigma;
	double tau;
	
	Erg(double t, double h, double G, double sigma, double tau){
		this.t = t;
		this.h = h;
		this.G = G;
		this.sigma = sigma;
		this.tau = tau;
	}
}

class zero2kl implements Fzero_methods{

	@Override
	public double f_to_zero(double h) {
		double f;
		
		f = -Sandwich.kappa*Math.sqrt(Sandwich.E_haut*Sandwich.now_t*Sandwich.E_kern/h)-Sandwich.M/(h*Sandwich.now_t)+Sandwich.F/(2.*Sandwich.now_t);
		
		return f;
	}
	
}