Hi, HK
I attached one of the problems using function plot response that I’ve created 
and used in my Electric Circuits class.
It works fine except there are several  peculiarities that one has to keep in 
mind when using function plot response.
Most of them I’ve learned by trial and error.
1. Function plot problem cannot be a part of composite page.
2. There are certain issues with checking “prior tries” in case student would 
say that his/her previous try was correct. Lon-CAPA stores prior tries for 
function plot response in a form of some array that I wasn’t be able to read or 
interpret.
3. Once in a while (one out of 40 students) encounter strange issue: after they 
submit the plot, LON-CAPA response is “not a function”. No matter what you do 
after that, it would still display this message: change the curve, do not 
change the curve etc. It does not depend on the OS – windows or MAC. We were 
not able to figure out what causes it.

Due to issues 2,3 I do not use FPR in exams, only in homework.
Please let me know if I can be of more help.
Thanks,
Grigory

From: LON-CAPA-users [mailto:lon-capa-users-boun...@mail.lon-capa.org] On 
Behalf Of H. K. Ng
Sent: Saturday, June 1, 2019 12:10
To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org>
Subject: [LON-CAPA-users] functionplotresponse problems

Good morning,

I am looking for examples of functionplotresponse problems (one where a student 
can resize/drag a vector,..) Let me know if you don't mind sharing the source 
codes. Thanks.

Regards,
-hk

<problem>
<script type="loncapa/perl">
# Ulaby, Circuits, Problem 9.17(a) 
# H(om)=($A1+j*om)/($A2+j*om)";
# converting to standard form of H(om):
# H=($A1/$A2)*(1+j*om/$A1)/(1+j*om/$A2)
# $A1=&random(60,120,10);
$A1=10;
$A2=50;
$H="H(om)=($A1+j*om)/($A2+j*om)";
$A=$A1/$A2;
$omc1=$A1;
$omc2=$A2;
$AdB=20*&log10($A);
# om ranges from 0.01 rad/s to 1000 rad/s
# On log scale, z=log10(om), z ranges from -2 to 3
# MdB=20log10(A0)+20log10(om)-20log10(1+jom/omc)
$zc1=&log10($omc1); # Z-coordinate for om=omc
$zc2=&log10($omc2);
$zmin=-2.5; # min x-axis
$zmax=3.5; # max x-axis
$zinit=-2; # start function plot
$zend=3; # end plot

# Magnitude plot
 $f0="$AdB"; #from z=-2 to zc1
 $f1="$AdB+20*(x-$zc1)"; #z= zc1 to zc2
 $f2="0"; #z = zc2 to zend
 # check points
$Minit=$AdB; #value at zinit;
$zchk1=$zc1; #check point at omc1
$Mchk1=$AdB;
$zchk2=$zc2; #check point at omc2
$Mchk2=0;
$Mend=0;

$NctrM=4; # number of control points on spline

#Phase plot 
$zc1l=$zc1-1; #start 1st slope
$zc1r=$zc1+1; #end 1st slope
$zc2l=$zc2-1; #start 2nd slope
$zc2r=$zc2+1; #end 2nd slope

$ph1=0; # from zinit to zc1l
$ph2="45*(x-$zc1l)"; # from zc1l to zc2l
$ph3="45*($zc2l-$zc1l)"; # from zc2l to zc1r
$ph4="45*($zc2l-$zc1l)-45*(x-$zc1r)"; # from zc1r to zc2r  
$ph5=0;
 # check points
$Phinit=0;
$Phchk1=0; # at zc1l
$Phchk2=45*($zc2l-$zc1l); #at zc2l
$Phchk3=45*($zc2l-$zc1l); #at zc1r
$Phchk4=0; #at zc2r
$Phchk5=0; #at zend

$NctrPh=6; # number of control points on spline for Phase plot

     </script>
<startouttext /> <br />
The voltage transfer function given by 
         <br />$H
    <br /> Using the graph windows below, generate Bode plots for the magnitude 
and phase of the transfer function H 
    <br /> in the om range from om_min=0.01 to om_max=1000 rad/s. 
   <br />  Note that the omega axis has logarithimc scale and is labeled in 
log10(om) units.
<br /> Make sure that your graph spreads over the entire above range of omega,
<br /> i.e it starts at or to the left of om_min and ends at or to the right of 
om_max.
    <br />  Drag the blue dots on the curve to obtain the correct coordinates 
of the Bode plot.
    <br />  Drag or rotate the black dots (handles) to change the corner shapes 
of the curve.
    <endouttext />
    
    <part id="11">
<br />  <startouttext />
 <br /> Generate Bode plot for the magnitude of transfer function.  
   <br /> <br />      <endouttext />
        <br />
        <parameter name="maxtries" default="5" id="12" type="int_pos" 
description="Maximum Number of Tries" />
    <functionplotresponse 
answerdisplay="$f0:$zinit:$zc1,$f1:$zc1:$zc2,$f2:$zc2:$zend" xmin="$zmin" 
xaxisvisible="yes" ymax="30" xlabel="lg(om)" ymin="-30" gridvisible="yes" 
ylabel="M, 10 dB/div" xmax="$zmax" id="14" yaxisvisible="yes">
<functionplotelements>
       <comment> You can move any block here to disable it 
 <backgroundplot xinitial="$zinit" function="$f0" fixed="yes" xfinal="$zc1" />
<backgroundplot xinitial="$zc1" function="$f1" fixed="yes" xfinal="$zc2" />
 <backgroundplot xinitial="$zc2" function="$f2" fixed="yes" xfinal="$zend" /> 
    </comment>   
 
    <spline scalex="1" initx="-0.5" inity="0" index="A" order="$NctrM" 
scaley="1" />
</functionplotelements>

        <functionplotruleset>
<functionplotrule xinitial="$zinit" derivativeorder="0" relationship="eq" 
value="$Minit" percenterror="6" index="init" />
<functionplotrule xinitial="$zchk1" derivativeorder="0" relationship="eq" 
value="$Mchk1" percenterror="6" index="chk1" />
<functionplotrule xinitial="$zchk2" derivativeorder="0" relationship="eq" 
value="$Mchk2" percenterror="6" index="chk2" />
<functionplotrule xinitial="$zend" derivativeorder="0" relationship="eq" 
value="$Mend" percenterror="6" index="End" />

</functionplotruleset>
</functionplotresponse>
</part>
              <part id="21">
<startouttext />
 <br /> Generate Bode plot for the phase of transfer function.  
 <br /> <br />        <endouttext />
<br />
  <parameter name="maxtries" default="5" description="Maximum Number of Tries" 
id="22" type="int_pos" />
    <functionplotresponse 
answerdisplay="$ph1:$zinit:$zc1l,$ph2:$zc1l:$zc2l,$ph3:$zc2l:$zc1r,$ph4:$zc1r:$zc2r,$ph5:$zc2r:$zend"
 xmin="$zmin" xaxisvisible="yes" ymax="95" xlabel="lg(om)" ymin="-95" 
gridvisible="yes" ylabel="Phase, 20 deg/div" xmax="$zmax" id="23" 
yaxisvisible="yes">
    <functionplotelements>
    <comment>
<backgroundplot xinitial="$zinit" function="$ph1" fixed="yes" xfinal="$zc1l" />
<backgroundplot xinitial="$zc1l" function="$ph2" fixed="yes" xfinal="$zc2l" />
<backgroundplot xinitial="$zc2l" function="$ph3" fixed="yes" xfinal="$zc1r" />
<backgroundplot xinitial="$zc1r" function="$ph4" fixed="yes" xfinal="$zc2r" />  
      
<backgroundplot xinitial="$zc2r" function="$ph5" fixed="yes" xfinal="$zend" />  
  </comment>

 <spline scalex="1" initx="-0.5" inity="0" index="B" order="$NctrPh" scaley="1" 
/>
</functionplotelements>

 <functionplotruleset>
            
<functionplotrule xinitial="$zinit" derivativeorder="0" relationship="eq" 
value="$Phinit" percenterror="6" index="init" />
<functionplotrule xinitial="$zc1l" derivativeorder="0" relationship="eq" 
value="$Phchk1" percenterror="6" index="chk1" />
<functionplotrule xinitial="$zc2l" derivativeorder="0" relationship="eq" 
value="$Phchk2" percenterror="6" index="chk2" />
<functionplotrule xinitial="$zc1r" derivativeorder="0" relationship="eq" 
value="$Phchk3" percenterror="6" index="chk3" />
<functionplotrule xinitial="$zc2r" derivativeorder="0" relationship="eq" 
value="$Phchk4" percenterror="6" index="chk4" />     
<functionplotrule xinitial="$zend" derivativeorder="0" relationship="eq" 
value="$Phchk5" percenterror="6" index="end" />
    
</functionplotruleset>
</functionplotresponse>
    </part>  
</problem>


_______________________________________________
LON-CAPA-users mailing list
LON-CAPA-users@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

Reply via email to