Editing Ocs package

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 73: Line 73:
A circuit is represented in OCS by a struct variable with the fields listed below
A circuit is represented in OCS by a struct variable with the fields listed below


{{Code|OCS structure format |<syntaxhighlight lang="octave" style="font-size:13px">
{{Code|CIR file format |<syntaxhighlight lang="text" style="font-size:13px">
cir_struct =
cir_struct =
{
{
Line 186: Line 186:
{{Code|Model evaluator file for simple MOSFET models |<syntaxhighlight lang="octave" style="font-size:13px">
{{Code|Model evaluator file for simple MOSFET models |<syntaxhighlight lang="octave" style="font-size:13px">
function [a, b, c] =...
function [a, b, c] =...
func (string , pvmatrix(i ,:) , extvar , intvar , t)
func (string , m(i ,:) , extvar , intvar , t)
</syntaxhighlight>}}
</syntaxhighlight>}}
i.e. it should get as inputs:
i.e. it should get as inputs:
Line 574: Line 574:
}}
}}


=== A circuit with a linear VCVS ===
To parse an IFF format netlist of the VCVS circuit  we can use the following command
{{Code|Load the VCVS circuit structure parsing an IFF netlist |<syntaxhighlight lang="octave" style="font-size:13px">
outstruct = prs_iff ("vcvs");
</syntaxhighlight>
}}
The IFF netlist consists of the .cir file named "vcvs.cir" shown below
{{Code|IFF netlist for the VCVS circuit (.cir file)|<syntaxhighlight lang="text" style="font-size:13px">
%0.1b1
% A Simple linear VCVS example
% Input voltage sources
Mvoltagesources sinwave 2 4
1 4
Ampl      f      delay    shift
1        1      0.0      0.0
1 0
END
% VCVS
Mvcvs LIN 4 1
1 1
Gain
5.0
2 0 1 0
% Resistor
Mresistors LIN  2 1
1 1
R
1
1 2
END
</syntaxhighlight>
}}
and of the .nms file named "and.nms shown below
{{Code|IFF netlist for the VCVS circuit (.nms file)|<syntaxhighlight lang="text" style="font-size:13px">
% 0.1b1
1 V_controller
2 V_controlled
</syntaxhighlight>
}}
The implementation for the VCVS with linear gain is shown below
{{Code|Model evaluator file for simple VCVS model |<syntaxhighlight lang="octave" style="font-size:13px">
function [a,b,c] = Mvcvs (string, parameters, parameternames, extvar,
                          intvar, t)
  if isempty(intvar)
    intvar = 0;
  endif
  switch string
      ##LCR part
    case "LIN"
      for ii=1:length(parameternames)
eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])
      endfor
     
      j = intvar (1);
      Vin = extvar (3) - extvar (4);
      V = Vin * Gain;
     
      a = zeros (5);     
      b = [0  0  0    0    1;
          0  0  0    0    -1;
          0  0  0    0    0;
          0  0  0    0    0;
          1 -1  -Gain  Gain  0];
     
      c = [0 0 0 0 0];
      break
    otherwise
      error (["unknown section:" string])
  endswitch
endfunction
</syntaxhighlight>
}}
[[File:VCVS_result.png|thumb| Result of the VCVS simulation]]
To run a simulation with this circuit use the following commands:
{{Code|Run a simple transient simulation with the VCVS circuit |<syntaxhighlight lang="octave" style="font-size:13px">
>> x = [0 0 0 0]';
>> t = linspace(0,1,50);
>> [out, niter] = tst_backward_euler (outstruct, x, t, 1e-6, 100, pltvars, [0 1]);
</syntaxhighlight>
}}


=== Creating a model for a memristor device ===
=== Creating a model for a memristor device ===


To demonstrate how to write a model evaluator file (SBN file), we
To demonstrate how to write a model evaluator file (SBN file), we
will discuss the simplest memristor model shown in this paper by [[User:KaKiLa| KaKiLa]] et al.:
will discuss the simplest memristor model shown in this paper by [[User:KaKiLa| KaKiLa]] et al. (KaKiLa, can you please add a reference to the paper?)
 
Carbajal, J. P. et al.
[http://www.mitpressjournals.org/doi/abs/10.1162/NECO_a_00694?journalCode=neco#.VgFNn9tSukp Memristor models for machine learning].
Neural Computation, 27(3), 2015.
doi:10.1162/NECO_a_00694


The device model is presented in the original paper as
The device model is presented in the original paper as
Line 911: Line 811:


The results are shown in the figure to the right.
The results are shown in the figure to the right.
== Dependencies ==
=== Odepkg ===
Ocs depends on [[Odepkg | ''odepkg'']] that is not anymore part of the [[Octave Forge]] project.
However, ''odepkg'' still works as of 2020, and instructions to install it are available [[Odepkg | in this wiki]].
[[Category:Octave Forge]]
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: