unit NeutronsConvertForm;
{ A FAIRE }
{ * conversion bi <-> sigma }
{ * verifier le signe de beta }

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, StdCtrls, EditReal, ExtCtrls, constants, JvComponent,
  JvFormPlace;

type
  TConversionsNeutronsForm = class(TForm)
    Panel1: TPanel;
    deltaBox: TEditReal;
    betaBox: TEditReal;
    Panel2: TPanel;
    Label3: TLabel;
    Label4: TLabel;
    bBox: TEditReal;
    lambdaBox: TEditReal;
    biBox: TEditReal;
    Label5: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    densityBox: TEditReal;
    Label6: TLabel;
    JvFormPlace1: TJvFormPlace;
    Panel3: TPanel;
    Label7: TLabel;
    sigma: TEditReal;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    Label8: TLabel;
    Mbox: TEditReal;
    Label9: TLabel;
    deltaMbox: TEditReal;
    bMbox: TEditReal;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    Label10: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure MboxKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure bMboxKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ConversionsNeutronsForm: TConversionsNeutronsForm;

implementation

{$R *.dfm}

procedure TConversionsNeutronsForm.SpeedButton1Click(Sender: TObject);
var lambda,density:double;
begin
     lambda:=lambdaBox.value*1e-9;
     density:=densityBox.value*1e28;
     deltaBox.value := lambda * lambda  / (2*pi) * density * bBox.value * 1e-15 * 1e6; { ok }
     betaBox.value := lambda * lambda  / (2*pi) * density * biBox.value *1e-15 * 1e6; { signe? }
     deltaMBox.value := lambda * lambda  / (2*pi) * density * bMBox.value *1e-15 * 1e6; { signe? }
end;

procedure TConversionsNeutronsForm.SpeedButton2Click(Sender: TObject);
var lambda,density:double;
begin
     lambda:=lambdaBox.value*1e-9;
     density:=densityBox.value*1e28;
     bBox.value := 1e15 * deltaBox.value / (lambda * lambda)  * (2*pi) / (density * 1e6);
     biBox.Value := 1e15 * betaBox.value / (lambda * lambda)  * (2*pi) / (density * 1e6);
     bMBox.Value := 1e15 * deltaMBox.value / (lambda * lambda)  * (2*pi) / (density * 1e6);
     { mise a jour de l'aimantation }
     Mbox.value := bMBox.value*1e-15 / mn * (2*pi*hb2) / abs(mun) * (densityBox.value*1e28)
end;

procedure TConversionsNeutronsForm.FormCreate(Sender: TObject);
begin
  WindowState:=wsMinimized;
end;

{ conversion de bi en barns }
procedure TConversionsNeutronsForm.SpeedButton3Click(Sender: TObject);
begin
  sigma.value := 1e28 * bibox.value*1e-15 / (2*pi) * (lambdaBox.value*1e-9) * (4*pi);
end;

procedure TConversionsNeutronsForm.SpeedButton4Click(Sender: TObject);
begin
  bibox.value:=1e15 * sigma.value * 1e-28 * (2*pi) / (lambdaBox.value*1e-9) / (4*pi);
end;

{ conversion de l'aimantation en bM }
procedure TConversionsNeutronsForm.MboxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
   if key=13 then bMBox.value := 1e15 * mn / (2*pi*hb2) * abs(mun) * mu0 * Mbox.value * muB;
end;

procedure TConversionsNeutronsForm.bMboxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
   if key=13 then Mbox.value := bMBox.value*1e-15 / mn * (2*pi*hb2) / abs(mun)/ mu0 / muB;
end;

end.
