These are chat archives for phaustin/numeric_discussion

14th
Oct 2015
Philip Austin
@phaustin
Oct 14 2015 00:16
I'm having difficulty understanding how the class code works... at the moment, I'm trying to figure out a way to properly loop over different L values to create an array of corresponding Te values, and I'm stumped
My hint says: To do this, I overrode
the value of L from the init file by passing a new value into
the IntegCoupling constructor.
What I meant was something like this
import numpy as np
class Base:
    #
    # this constructor is called first
    #
    def __init__(self,basevar):
        self.L=basevar


class Child(Base):
    #
    # this class changes the initialization
    # to add a new variable
    #
    def __init__(self,a,L):
        super().__init__(a)
        #
        # change the L in the child class
        #
        self.L=L

Lvals=np.linspace(0,100,11)

#
# now make 10 children, each with a different value of L
#
a=5
for theL in Lvals:
   newItem=Child(a,theL)
   print('set L value in child class to {:3.0f}'.format(newItem.L))
Philip Austin
@phaustin
Oct 14 2015 00:21
If you run this, it prints out:
set L value in child class to   0
set L value in child class to  10
set L value in child class to  20
set L value in child class to  30
set L value in child class to  40
set L value in child class to  50
set L value in child class to  60
set L value in child class to  70
set L value in child class to  80
set L value in child class to  90
set L value in child class to 100
In the same way, you can change the value that Integrator sets for self.uservars.L by overwriting it in the constructor for IntegCoupling. Then you can make an IntegCoupling instance for each L value, run it, and save the final daisy values (checing to make sure they’re at equilibrium)
Philip Austin
@phaustin
Oct 14 2015 00:30
Once you have the daisy fractions, you can calculate by reusing code from derivs5 in a separate function, or you could modify derivs5 so it saves Te as a new variable
I meant modify timeloop5fixed so it returns $Te$ in addition to the daisies
Philip Austin
@phaustin
Oct 14 2015 00:43
This message was deleted

look for these lines in Integ51:

initvars = namedtuple('initvars', self.config['initvars'].keys())
 self.initvars = initvars(**self.config['initvars’])

and change L in self.config before you make the named tuple initvars