ftp.nice.ch/pub/next/science/physics/COSY_PAK.081.N.s.tar.gz#/COSY_PAK_Main/COSYPAK/chap3.m

This is chap3.m in view mode; [Download] [Up]

(* 
**********************************************************

		 COSY_PAK package chap3.m		

**********************************************************
*)


If [ TrueQ[ $VersionNumber >= 2.0 ],
     Off[ General::spell ];
     Off[ General::spell1 ] ]
     
(*  B E G I N     P A C K A G E  *)


BeginPackage["COSYPAK`chap3`",,"SignalProcessing`Support`SigProc`", 
		"SignalProcessing`Analog`LaPlace`",
		"SignalProcessing`Analog`InvLaPlace`"]	     

Response::usage = "Response[ transf, Input, s, {TimeVar, StartTime, EndTime}, gopts]: Plots the output of transfer function `transf' with Laplace input signal `Input'.  The Laplace variable is `s'.  The output graph uses the variable `TimeVar' and starts at `StartTime' and ends at `EndTime'.  Returns the output variable as a function of time `t'.";

SecOrder::usage = "SecOrder[zeta, wn, t]: Gives the unit step response value at time instant t for a standard second order system wn2/(s2 + 2z wn s + wn2) with the damping ratio z=zeta and natural frequency wn =wn. Returns instantaneous value of the step response output variable at time instant `t'.";

Begin["`Private`"]

SecOrder/:SecOrder[damp_,wn_,t_]:=
	Module[{wd},wd = wn Sqrt[1-damp^2]; 
	 	1-E^(-damp wn t) (Cos[wd t]+damp/Sqrt[1-damp^2] Sin[wd t])]/;
	 	0 <= damp < 1
	
SecOrder/:SecOrder[damp_,wn_,t_]:= 1 - E^(-wn t)( 1 + wn t)/;
			Abs[damp - 1] < 0.0001
			
SecOrder/:SecOrder[damp_,wn_,t_]:=
	Module[{s1,s2,temp}, temp = Sqrt[damp^2 -1];
	 	s1 = (damp + temp) wn ;
	 	s2 = (damp - temp) wn ;
	 	y = 1 + wn/2/temp ( (E^(-s1 t))/s1 - (E^(-s2 t))/s2)
	 	]/;damp > 1

(*

*)	
Response[transf_,input_,s_,{t_,tmin_,tmax_},opts___] :=
Module[{outputlp ,output,inputfunc},
	outputlp = transf input;
	output = InvLaPlace[outputlp,s,t,Dialogue->False,Apart->All];
	output = Simplify[ComplexExpand[output]];
	inputfunc = InvLaPlace[input,s,t,Dialogue->False,Apart->All];
	inputfunc = Simplify[ComplexExpand[inputfunc]];
	
	(* Apply SignalPlot to plot output in solid line and
	    inputfunc in dash line *)	
	SignalPlot[output + inputfunc I,{t,tmin,tmax},
		FrameLabel->{"Time","Y(t)","Time Response of G(s) "," "},
		Frame->True,PlotRange -> All,GridLines->Automatic, 
        FrameTicks -> {Automatic, Automatic,Automatic, Automatic},
		opts];
	Return[output]					
		
		]/; tmin < tmax


End[];
EndPackage[];

(*  E N D     P A C K A G E  *)

If [ TrueQ[ $VersionNumber >= 2.0 ],
     On[ General::spell ];
     On[ General::spell1 ] ]

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.