function current=CircuitGetCurrent(Circuit,component_name)
% return current through circuit component component_name

current=[];
BranchCurrents=Circuit.BranchCurrents;
Schematic=Circuit.Schematic;
for nBranch=1:length(Schematic)
    Branch=Schematic{nBranch,1};
    Components=Branch.Components;
    for i=1:length(Components)
        component=Components{i,1};
        if strcmp(component.name,component_name)
            current=BranchCurrents(nBranch);
            return
        end
    end
end
if isempty(current), error(['Undefined circuit component ' component_name]); end