当前位置: 首页>>代码示例>>Python>>正文


Python PropertyTree.put_double方法代码示例

本文整理汇总了Python中pycap.PropertyTree.put_double方法的典型用法代码示例。如果您正苦于以下问题:Python PropertyTree.put_double方法的具体用法?Python PropertyTree.put_double怎么用?Python PropertyTree.put_double使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycap.PropertyTree的用法示例。


在下文中一共展示了PropertyTree.put_double方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testRetrieveData

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def testRetrieveData(self):
     try:
         from h5py import File
     except ImportError:
         print('module h5py not found')
         return
     device_database = PropertyTree()
     device_database.put_string('type', 'SeriesRC')
     device_database.put_double('series_resistance', R)
     device_database.put_double('capacitance', C)
     device = EnergyStorageDevice(device_database, MPI.COMM_WORLD)
     eis_database  = setup_expertiment()
     eis_database.put_int('steps_per_decade', 1)
     eis_database.put_int('steps_per_cycle', 64)
     eis_database.put_int('cycles', 2)
     eis_database.put_int('ignore_cycles', 1)
     fout = File('trash.hdf5', 'w')
     spectrum_data = measure_impedance_spectrum(device, eis_database, fout)
     fout.close()
     fin = File('trash.hdf5', 'r')
     retrieved_data = retrieve_impedance_spectrum(fin)
     fin.close()
     print(spectrum_data['impedance']-retrieved_data['impedance'])
     print(retrieved_data)
     self.assertEqual(linalg.norm(spectrum_data['frequency'] -
                                  retrieved_data['frequency'], inf), 0.0)
     # not sure why we don't get equality for the impedance
     self.assertLess(linalg.norm(spectrum_data['impedance'] -
                                 retrieved_data['impedance'], inf), 1e-10)
开发者ID:danialfaghihi,项目名称:Cap,代码行数:31,代码来源:test_impedance_spectroscopy.py

示例2: testSeriesRC

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def testSeriesRC(self):
     # make series RC equivalent circuit
     device_database = PropertyTree()
     device_database.put_string('type', 'SeriesRC')
     device_database.put_double('series_resistance', R)
     device_database.put_double('capacitance', C)
     device = EnergyStorageDevice(device_database, MPI.COMM_WORLD)
     # setup experiment and measure
     eis_database = setup_expertiment()
     spectrum_data = measure_impedance_spectrum(device, eis_database)
     # extract data
     f = spectrum_data['frequency']
     Z_computed = spectrum_data['impedance']
     R_computed = real(Z_computed)
     X_computed = imag(Z_computed)
     M_computed = 20*log10(absolute(Z_computed))
     P_computed = angle(Z_computed)*180/pi
     # compute the exact solution
     Z_exact = R+1/(1j*C*2*pi*f)
     R_exact = real(Z_exact)
     X_exact = imag(Z_exact)
     M_exact = 20*log10(absolute(Z_exact))
     P_exact = angle(Z_exact)*180/pi
     # ensure the error is small
     max_phase_error_in_degree = linalg.norm(P_computed-P_exact, inf)
     max_magniture_error_in_decibel = linalg.norm(M_computed-M_exact, inf)
     print('max_phase_error_in_degree = {0}'.format(max_phase_error_in_degree))
     print('max_magniture_error_in_decibel = {0}'.format(max_magniture_error_in_decibel))
     self.assertLessEqual(max_phase_error_in_degree, 1)
     self.assertLessEqual(max_magniture_error_in_decibel, 0.2)
开发者ID:danialfaghihi,项目名称:Cap,代码行数:32,代码来源:test_impedance_spectroscopy.py

示例3: test_evolve_constant_voltage

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_evolve_constant_voltage(self):
     ptree = PropertyTree()
     ptree.put_string('mode', 'constant_voltage')
     ptree.put_double('voltage', 2.1)
     evolve_one_time_step = TimeEvolution.factory(ptree)
     evolve_one_time_step(device, 0.1)
     self.assertEqual(device.get_voltage(), 2.1)
开发者ID:danialfaghihi,项目名称:Cap,代码行数:9,代码来源:test_time_evolution.py

示例4: test_no_name

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_no_name(self):
     ptree = PropertyTree()
     ptree.put_double('initial_voltage', 0)
     ptree.put_double('final_voltage', 0)
     ptree.put_double('scan_limit_1', 1)
     ptree.put_double('scan_limit_2', 0)
     ptree.put_double('step_size', 0.1)
     ptree.put_double('scan_rate', 1)
     ptree.put_int('cycles', 1)
     cv = CyclicVoltammetry(ptree)
     try:
         cv.run(device)
     except:
         self.fail('calling run without data should not raise')
     data = initialize_data()
     cv.run(device, data)
     voltage = array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.,
                      0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.],
                     dtype=float)
     time = linspace(0, 2, 21)
     try:
         testing.assert_array_almost_equal(data['voltage'], voltage)
         testing.assert_array_almost_equal(data['time'], time)
     except AssertionError as e:
         print(e)
         self.fail()
开发者ID:danialfaghihi,项目名称:Cap,代码行数:28,代码来源:test_voltammetry.py

示例5: test_evolve_constant_current

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_evolve_constant_current(self):
     ptree = PropertyTree()
     ptree.put_string('mode', 'constant_current')
     ptree.put_double('current', 100e-3)
     evolve_one_time_step = TimeEvolution.factory(ptree)
     evolve_one_time_step(device, 0.1)
     self.assertEqual(device.get_current(), 100e-3)
开发者ID:danialfaghihi,项目名称:Cap,代码行数:9,代码来源:test_time_evolution.py

示例6: test_evolve_constant_load

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_evolve_constant_load(self):
     ptree = PropertyTree()
     ptree.put_string('mode', 'constant_load')
     ptree.put_double('load', 120)
     evolve_one_time_step = TimeEvolution.factory(ptree)
     evolve_one_time_step(device, 0.1)
     self.assertAlmostEqual(device.get_voltage()/device.get_current(), -120)
开发者ID:danialfaghihi,项目名称:Cap,代码行数:9,代码来源:test_time_evolution.py

示例7: test_time_limit

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_time_limit(self):
     ptree = PropertyTree()
     ptree.put_string('end_criterion', 'time')
     ptree.put_double('duration', 15)
     time_limit = EndCriterion.factory(ptree)
     time_limit.reset(0.0, device)
     self.assertFalse(time_limit.check(2.0, device))
     self.assertTrue(time_limit.check(15.0, device))
     self.assertTrue(time_limit.check(60.0, device))
开发者ID:ORNL-CEES,项目名称:Cap,代码行数:11,代码来源:test_end_criterion.py

示例8: test_verification_with_equivalent_circuit

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_verification_with_equivalent_circuit(self):
     R = 50e-3   # ohm
     R_L = 500   # ohm
     C = 3       # farad
     # setup EIS experiment
     ptree = PropertyTree()
     ptree.put_string('type', 'ElectrochemicalImpedanceSpectroscopy')
     ptree.put_double('frequency_upper_limit', 1e+4)
     ptree.put_double('frequency_lower_limit', 1e-6)
     ptree.put_int('steps_per_decade', 3)
     ptree.put_int('steps_per_cycle', 1024)
     ptree.put_int('cycles', 2)
     ptree.put_int('ignore_cycles', 1)
     ptree.put_double('dc_voltage', 0)
     ptree.put_string('harmonics', '3')
     ptree.put_string('amplitudes', '5e-3')
     ptree.put_string('phases', '0')
     eis = Experiment(ptree)
     # setup equivalent circuit database
     device_database = PropertyTree()
     device_database.put_double('series_resistance', R)
     device_database.put_double('parallel_resistance', R_L)
     device_database.put_double('capacitance', C)
     # analytical solutions
     Z = {}
     Z['SeriesRC'] = lambda f: R + 1 / (1j * C * 2 * pi * f)
     Z['ParallelRC'] = lambda f: R + R_L / (1 + 1j * R_L * C * 2 * pi * f)
     for device_type in ['SeriesRC', 'ParallelRC']:
         # create a device
         device_database.put_string('type', device_type)
         device = EnergyStorageDevice(device_database)
         # setup experiment and measure
         eis.reset()
         eis.run(device)
         f = eis._data['frequency']
         Z_computed = eis._data['impedance']
         # compute the exact solution
         Z_exact = Z[device_type](f)
         # ensure the error is small
         max_phase_error_in_degree = linalg.norm(
             angle(Z_computed) * 180 / pi - angle(Z_exact) * 180 / pi,
             inf)
         max_magniture_error_in_decibel = linalg.norm(
             20 * log10(absolute(Z_exact)) - 20 *
             log10(absolute(Z_computed)),
             inf)
         print(device_type)
         print(
             '-- max_phase_error_in_degree = {0}'.format(max_phase_error_in_degree))
         print(
             '-- max_magniture_error_in_decibel = {0}'.format(max_magniture_error_in_decibel))
         self.assertLessEqual(max_phase_error_in_degree, 1)
         self.assertLessEqual(max_magniture_error_in_decibel, 0.2)
开发者ID:ORNL-CEES,项目名称:Cap,代码行数:55,代码来源:test_impedance_spectroscopy.py

示例9: test_consistency_pycap_simulation

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
    def test_consistency_pycap_simulation(self):
        # 
        # weak run test; simply ensures that Dualfoil object
        # can be run with pycap.Charge
        #
        df1 = Dualfoil(path=path)  # will use pycap
        df2 = Dualfoil(path=path)  # manual runs
        im = df_manip.InputManager(path=path)

        # testing a charge-to-hold-const-voltage
        # manual 
        # use InputManager to set the input file
        c = -12.0  # constant current
        im.add_new_leg(c, 5.0, 1)
        df1.run()
        df1.outbot.update_output()
        v = 4.54  # constant voltage
        im.add_new_leg(v, 5.0, 0)
        df1.run()
        df1.outbot.update_output()
        
        # pycap simulation
        # build a ptree input
        ptree = PropertyTree()
        ptree.put_double('time_step', 300.0)  # 5 minutes
        ptree.put_string('charge_mode', 'constant_current')
        ptree.put_double('charge_current', 12.0)
        ptree.put_string('charge_stop_at_1', 'voltage_greater_than')
        ptree.put_double('charge_voltage_limit', 4.54)
        ptree.put_bool('charge_voltage_finish', True)
        # hold end voltage after either 5 minutes have passed
        # OR current falls under 1 ampere
        ptree.put_double('charge_voltage_finish_max_time', 300.0)
        ptree.put_double('charge_voltage_finish_current_limit', 1.0)

        const_current_const_voltage = Charge(ptree)
        const_current_const_voltage.run(df2)

        # check the output lists of both devices
        o1 = df1.outbot.output
        o2 = df2.outbot.output
        self.assertEqual(len(o1['time']), len(o2['time']))
        for i in range(len(o1['time'])):
            self.assertAlmostEqual(o1['time'][i], o2['time'][i])
            # BELOW: relaxed delta for voltage
            # REASON: dualfoil cuts off its voltages at 5
            #   decimal places, meaning that this end-digit
            #   is subject to roundoff errors
            error = 1e-5
            self.assertAlmostEqual(o1['voltage'][i], o2['voltage'][i],
                                   delta=error)
            self.assertAlmostEqual(o1['current'][i], o2['current'][i])
开发者ID:iSchomer,项目名称:Dualfoil_Storage_Device,代码行数:54,代码来源:test_energy_storage_device.py

示例10: test_retrieve_data

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
    def test_retrieve_data(self):
        ptree = PropertyTree()
        ptree.put_string('type', 'SeriesRC')
        ptree.put_double('series_resistance', 100e-3)
        ptree.put_double('capacitance', 2.5)
        device = EnergyStorageDevice(ptree)

        ptree = PropertyTree()
        ptree.put_string('type', 'ElectrochemicalImpedanceSpectroscopy')
        ptree.put_double('frequency_upper_limit', 1e+2)
        ptree.put_double('frequency_lower_limit', 1e-1)
        ptree.put_int('steps_per_decade', 1)
        ptree.put_int('steps_per_cycle', 64)
        ptree.put_int('cycles', 2)
        ptree.put_int('ignore_cycles', 1)
        ptree.put_double('dc_voltage', 0)
        ptree.put_string('harmonics', '3')
        ptree.put_string('amplitudes', '5e-3')
        ptree.put_string('phases', '0')
        eis = Experiment(ptree)

        with File('trash.hdf5', 'w') as fout:
            eis.run(device, fout)
        spectrum_data = eis._data

        with File('trash.hdf5', 'r') as fin:
            retrieved_data = retrieve_impedance_spectrum(fin)

        print(spectrum_data['impedance'] - retrieved_data['impedance'])
        print(retrieved_data)
        self.assertEqual(linalg.norm(spectrum_data['frequency'] -
                                     retrieved_data['frequency'], inf), 0.0)
        # not sure why we don't get equality for the impedance
        self.assertLess(linalg.norm(spectrum_data['impedance'] -
                                    retrieved_data['impedance'], inf), 1e-10)
开发者ID:ORNL-CEES,项目名称:Cap,代码行数:37,代码来源:test_impedance_spectroscopy.py

示例11: test_constant_current_charge_for_given_time

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_constant_current_charge_for_given_time(self):
     ptree = PropertyTree()
     ptree.put_string('mode', 'constant_current')
     ptree.put_double('current', 5e-3)
     ptree.put_string('end_criterion', 'time')
     ptree.put_double('duration', 15.0)
     ptree.put_double('time_step', 0.1)
     stage = Stage(ptree)
     data = initialize_data()
     steps = stage.run(device, data)
     self.assertEqual(steps, 150)
     self.assertEqual(steps, len(data['time']))
     self.assertAlmostEqual(data['time'][-1], 15.0)
     self.assertAlmostEqual(data['current'][-1], 5e-3)
开发者ID:danialfaghihi,项目名称:Cap,代码行数:16,代码来源:test_stage.py

示例12: setup_expertiment

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
def setup_expertiment():
    eis_database = PropertyTree()
    eis_database.put_double('frequency_upper_limit', 1e+4)
    eis_database.put_double('frequency_lower_limit', 1e-6)
    eis_database.put_int('steps_per_decade', 3)
    eis_database.put_int('steps_per_cycle', 1024)
    eis_database.put_int('cycles', 2)
    eis_database.put_int('ignore_cycles', 1)
    eis_database.put_double('dc_voltage', 0)
    eis_database.put_string('harmonics', ' 3')
    eis_database.put_string('amplitudes', ' 5e-3')
    eis_database.put_string('phases', '0')

    return eis_database
开发者ID:danialfaghihi,项目名称:Cap,代码行数:16,代码来源:test_impedance_spectroscopy.py

示例13: test_setup_frequency_range

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_setup_frequency_range(self):
     ptree = PropertyTree()
     ptree.put_string('type', 'ElectrochemicalImpedanceSpectroscopy')
     # specify the upper and lower bounds of the range
     # the number of points per decades controls the spacing on the log
     # scale
     ptree.put_double('frequency_upper_limit', 1e+2)
     ptree.put_double('frequency_lower_limit', 1e-1)
     ptree.put_int('steps_per_decade', 3)
     eis = Experiment(ptree)
     print(eis._frequencies)
     f = eis._frequencies
     self.assertEqual(len(f), 10)
     self.assertAlmostEqual(f[0], 1e+2)
     self.assertAlmostEqual(f[3], 1e+1)
     self.assertAlmostEqual(f[9], 1e-1)
     # or directly specify the frequencies
     frequencies = [3, 2e3, 0.1]
     eis = Experiment(ptree, frequencies)
     self.assertTrue(all(equal(frequencies, eis._frequencies)))
开发者ID:ORNL-CEES,项目名称:Cap,代码行数:22,代码来源:test_impedance_spectroscopy.py

示例14: test_charge_constant_voltage

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_charge_constant_voltage(self):
     ptree = PropertyTree()
     ptree.put_string('charge_mode', 'constant_voltage')
     ptree.put_double('charge_voltage', 1.4)
     ptree.put_string('charge_stop_at_1', 'current_less_than')
     ptree.put_double('charge_current_limit', 1e-6)
     ptree.put_string('charge_stop_at_2', 'time')
     ptree.put_double('charge_max_duration', 60)
     ptree.put_double('time_step', 0.2)
     charge = Charge(ptree)
     data = initialize_data()
     charge.run(device, data)
     self.assertTrue(data['time'][-1] >= 60 or
                     abs(data['current'][-1]) <= 1e-6)
     self.assertAlmostEqual(data['voltage'][-1], 1.4)
开发者ID:ORNL-CEES,项目名称:Cap,代码行数:17,代码来源:test_charge_discharge.py

示例15: test_compound_criterion

# 需要导入模块: from pycap import PropertyTree [as 别名]
# 或者: from pycap.PropertyTree import put_double [as 别名]
 def test_compound_criterion(self):
     ptree = PropertyTree()
     ptree.put_string('end_criterion', 'compound')
     ptree.put_string('criterion_0.end_criterion', 'time')
     ptree.put_double('criterion_0.duration', 5.0)
     ptree.put_string('criterion_1.end_criterion', 'voltage_greater_than')
     ptree.put_double('criterion_1.voltage_limit', 2.0)
     # no default value for now
     self.assertRaises(KeyError, EndCriterion.factory, ptree)
     ptree.put_string('logical_operator', 'bad_operator')
     self.assertRaises(RuntimeError, EndCriterion.factory, ptree)
     ptree.put_string('logical_operator', 'or')
     compound_criterion = EndCriterion.factory(ptree)
     compound_criterion.reset(0.0, device)
     device.evolve_one_time_step_constant_voltage(0.1, 1.0)
     self.assertFalse(compound_criterion.check(3.0, device))
     self.assertTrue(compound_criterion.check(5.0, device))
     device.evolve_one_time_step_constant_voltage(0.1, 2.0)
     self.assertTrue(compound_criterion.check(3.0, device))
     self.assertTrue(compound_criterion.check(5.0, device))
     ptree.put_string('logical_operator', 'and')
     compound_criterion = EndCriterion.factory(ptree)
     compound_criterion.reset(0.0, device)
     device.evolve_one_time_step_constant_voltage(0.1, 1.0)
     self.assertFalse(compound_criterion.check(3.0, device))
     self.assertFalse(compound_criterion.check(5.0, device))
     device.evolve_one_time_step_constant_voltage(0.1, 2.0)
     self.assertFalse(compound_criterion.check(3.0, device))
     self.assertTrue(compound_criterion.check(5.0, device))
     ptree.put_string('logical_operator', 'xor')
     compound_criterion = EndCriterion.factory(ptree)
     compound_criterion.reset(0.0, device)
     device.evolve_one_time_step_constant_voltage(0.1, 1.0)
     self.assertFalse(compound_criterion.check(3.0, device))
     self.assertTrue(compound_criterion.check(5.0, device))
     device.evolve_one_time_step_constant_voltage(0.1, 2.0)
     self.assertTrue(compound_criterion.check(3.0, device))
     self.assertFalse(compound_criterion.check(5.0, device))
开发者ID:ORNL-CEES,项目名称:Cap,代码行数:40,代码来源:test_end_criterion.py


注:本文中的pycap.PropertyTree.put_double方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。