Search is not available for this dataset
text stringlengths 75 104k |
|---|
def upload_file(self, filepath):
"""
上传素材 (图片/音频/视频)
:param filepath: 本地文件路径
:return: 直接返回上传后的文件 ID (fid)
:raises NeedLoginError: 操作未执行成功, 需要再次尝试登录, 异常内容为服务器返回的错误数据
:raises ValueError: 参数出错, 错误原因直接打印异常即可 (常见错误内容: ``file not exist``: 找不到本地文件, ``audio too long``: 音频文件过长, ``... |
def send_file(self, fakeid, fid, type):
"""
向特定用户发送媒体文件
:param fakeid: 用户 UID (即 fakeid)
:param fid: 文件 ID
:param type: 文件类型 (2: 图片, 3: 音频, 15: 视频)
:raises NeedLoginError: 操作未执行成功, 需要再次尝试登录, 异常内容为服务器返回的错误数据
:raises ValueError: 参数出错, 错误原因直接打印异常即可 (常见错误内容: ``system ... |
def get_user_info(self, fakeid):
"""
获取指定用户的个人信息
返回JSON示例::
{
"province": "湖北",
"city": "武汉",
"gender": 1,
"nick_name": "Doraemonext",
"country": "中国",
"remark_name": "",
... |
def get_avatar(self, fakeid):
"""
获取用户头像信息
:param fakeid: 用户的 UID (即 fakeid)
:return: 二进制 JPG 数据字符串, 可直接作为 File Object 中 write 的参数
:raises NeedLoginError: 操作未执行成功, 需要再次尝试登录, 异常内容为服务器返回的错误数据
"""
url = 'https://mp.weixin.qq.com/misc/getheadimg?fakeid={fakeid}&token=... |
def get_new_message_num(self, lastid=0):
"""
获取新消息的数目
:param lastid: 最近获取的消息 ID, 为 0 时获取总消息数目
:return: 消息数目
"""
url = 'https://mp.weixin.qq.com/cgi-bin/getnewmsgnum?f=json&t=ajax-getmsgnum&lastmsgid={lastid}&token={token}&lang=zh_CN'.format(
lastid=lastid,
... |
def get_message_list(self, lastid=0, offset=0, count=20, day=7, star=False):
"""
获取消息列表
返回JSON示例::
{
"msg_item": [
{
"id": 206439583,
"type": 1,
"fakeid": "844735403",
... |
def get_message_voice(self, msgid):
"""
根据消息 ID 获取语音消息内容
:param msgid: 消息 ID
:return: 二进制 MP3 音频字符串, 可直接作为 File Object 中 write 的参数
:raises NeedLoginError: 操作未执行成功, 需要再次尝试登录, 异常内容为服务器返回的错误数据
:raises ValueError: 参数出错, 错误原因直接打印异常即可, 错误内容: ``voice message not exist``: msg参数无效... |
def _init_self_information(self):
"""
初始化公众号自身的属性值 (目前包括 ``Ticket`` 值 及 公众号自身的 ``fakeid`` 值)
:raises NeedLoginError: 操作未执行成功, 需要再次尝试登录, 异常内容为服务器返回的错误数据
"""
url = 'https://mp.weixin.qq.com/cgi-bin/home?t=home/index&lang=zh_CN&token={token}'.format(token=self.__token)
heade... |
def _init_plugin_token_appid(self):
"""
初始化公众号的 ``PluginToken`` 值及公众号自身的 ``appid`` 值
:raises NeedLoginError: 操作未执行成功, 需要再次尝试登录, 异常内容为服务器返回的错误数据
"""
if not self.__plugin_token or not self.__appid:
url = 'https://mp.weixin.qq.com/misc/pluginloginpage?action=stat_article... |
def set_appid_appsecret(self, appid, appsecret):
""" 设置当前 App ID 及 App Secret"""
self.__appid = appid
self.__appsecret = appsecret
self._update_crypto() |
def access_token(self):
""" 获取当前 access token 值, 本方法会自行维护 access token 有效性 """
self._check_appid_appsecret()
if callable(self.__access_token_getfunc):
self.__access_token, self.__access_token_expires_at = self.__access_token_getfunc()
if self.__access_token:
now... |
def jsapi_ticket(self):
""" 获取当前 jsapi ticket 值, 本方法会自行维护 jsapi ticket 有效性 """
self._check_appid_appsecret()
if callable(self.__jsapi_ticket_getfunc):
self.__jsapi_ticket, self.__jsapi_ticket_expires_at = self.__jsapi_ticket_getfunc()
if self.__jsapi_ticket:
now... |
def grant_access_token(self):
"""
获取 access token 并更新当前配置
:return: 返回的 JSON 数据包 (传入 access_token_refreshfunc 参数后返回 None)
"""
self._check_appid_appsecret()
if callable(self.__access_token_refreshfunc):
self.__access_token, self.__access_token_expires_at = self... |
def grant_jsapi_ticket(self):
"""
获取 jsapi ticket 并更新当前配置
:return: 返回的 JSON 数据包 (传入 jsapi_ticket_refreshfunc 参数后返回 None)
"""
self._check_appid_appsecret()
if callable(self.__jsapi_ticket_refreshfunc):
self.__jsapi_ticket, self.__jsapi_ticket_expires_at = self... |
def _update_crypto(self):
"""
根据当前配置内容更新 Crypto 类
"""
if self.__encrypt_mode in ['compatible', 'safe'] and self.__encoding_aes_key is not None:
if self.__token is None or self.__appid is None:
raise NeedParamError('Please provide token and appid parameters in ... |
def conf(self, conf):
""" 设置当前 WechatConf 实例 """
self.__conf = conf
self.__request = WechatRequest(conf=self.__conf) |
def check_signature(self, signature, timestamp, nonce):
"""
验证微信消息真实性
:param signature: 微信加密签名
:param timestamp: 时间戳
:param nonce: 随机数
:return: 通过验证返回 True, 未通过验证返回 False
"""
if not signature or not timestamp or not nonce:
return False
... |
def generate_jsapi_signature(self, timestamp, noncestr, url, jsapi_ticket=None):
"""
使用 jsapi_ticket 对 url 进行签名
:param timestamp: 时间戳
:param noncestr: 随机数
:param url: 要签名的 url,不包含 # 及其后面部分
:param jsapi_ticket: (可选参数) jsapi_ticket 值 (如不提供将自动通过 appid 和 appsecret 获取)
... |
def parse_data(self, data, msg_signature=None, timestamp=None, nonce=None):
"""
解析微信服务器发送过来的数据并保存类中
:param data: HTTP Request 的 Body 数据
:param msg_signature: EncodingAESKey 的 msg_signature
:param timestamp: EncodingAESKey 用时间戳
:param nonce: EncodingAESKey 用随机数
:ra... |
def response_text(self, content, escape=False):
"""
将文字信息 content 组装为符合微信服务器要求的响应数据
:param content: 回复文字
:param escape: 是否转义该文本内容 (默认不转义)
:return: 符合微信服务器要求的 XML 响应数据
"""
self._check_parse()
content = self._transcoding(content)
if escape:
... |
def response_image(self, media_id):
"""
将 media_id 所代表的图片组装为符合微信服务器要求的响应数据
:param media_id: 图片的 MediaID
:return: 符合微信服务器要求的 XML 响应数据
"""
self._check_parse()
response = ImageReply(message=self.__message, media_id=media_id).render()
return self._encrypt_res... |
def response_voice(self, media_id):
"""
将 media_id 所代表的语音组装为符合微信服务器要求的响应数据
:param media_id: 语音的 MediaID
:return: 符合微信服务器要求的 XML 响应数据
"""
self._check_parse()
response = VoiceReply(message=self.__message, media_id=media_id).render()
return self._encrypt_res... |
def response_video(self, media_id, title=None, description=None):
"""
将 media_id 所代表的视频组装为符合微信服务器要求的响应数据
:param media_id: 视频的 MediaID
:param title: 视频消息的标题
:param description: 视频消息的描述
:return: 符合微信服务器要求的 XML 响应数据
"""
self._check_parse()
title = sel... |
def response_music(self, music_url, title=None, description=None, hq_music_url=None, thumb_media_id=None):
"""
将音乐信息组装为符合微信服务器要求的响应数据
:param music_url: 音乐链接
:param title: 音乐标题
:param description: 音乐描述
:param hq_music_url: 高质量音乐链接, WIFI环境优先使用该链接播放音乐
:param thumb_me... |
def response_news(self, articles):
"""
将新闻信息组装为符合微信服务器要求的响应数据
:param articles: list 对象, 每个元素为一个 dict 对象, key 包含 `title`, `description`, `picurl`, `url`
:return: 符合微信服务器要求的 XML 响应数据
"""
self._check_parse()
for article in articles:
if article.get('title'... |
def group_transfer_message(self):
"""
将 message 群发到多客服系统
:return: 符合微信服务器要求的 XML 响应数据
"""
self._check_parse()
response = GroupTransferReply(message=self.__message).render()
return self._encrypt_response(response) |
def create_menu(self, menu_data):
"""
创建自定义菜单 ::
# -*- coding: utf-8 -*-
wechat = WechatBasic(appid='appid', appsecret='appsecret')
wechat.create_menu({
'button':[
{
'type': 'click',
... |
def upload_media(self, media_type, media_file, extension=''):
"""
上传多媒体文件
详情请参考 http://mp.weixin.qq.com/wiki/10/78b15308b053286e2a66b33f0f0f5fb6.html
:param media_type: 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb)
:param media_file: 要上传的文件,一个 File object 或 StringIO object
... |
def download_media(self, media_id):
"""
下载多媒体文件
详情请参考 http://mp.weixin.qq.com/wiki/10/78b15308b053286e2a66b33f0f0f5fb6.html
:param media_id: 媒体文件 ID
:return: requests 的 Response 实例
"""
return self.request.get(
'https://api.weixin.qq.com/cgi-bin/media/g... |
def move_user(self, user_id, group_id):
"""
移动用户分组
详情请参考 http://mp.weixin.qq.com/wiki/13/be5272dc4930300ba561d927aead2569.html
:param user_id: 用户 ID 。 就是你收到的 WechatMessage 的 source
:param group_id: 分组 ID
:return: 返回的 JSON 数据包
"""
return self.request.post(
... |
def get_user_info(self, user_id, lang='zh_CN'):
"""
获取用户基本信息
详情请参考 http://mp.weixin.qq.com/wiki/14/bb5031008f1494a59c6f71fa0f319c66.html
:param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source
:param lang: 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语
:return: 返回的 JSON 数据包
"""
... |
def get_followers(self, first_user_id=None):
"""
获取关注者列表
详情请参考 http://mp.weixin.qq.com/wiki/3/17e6919a39c1c53555185907acf70093.html
:param first_user_id: 可选。第一个拉取的OPENID,不填默认从头开始拉取
:return: 返回的 JSON 数据包
"""
params = dict()
if first_user_id:
par... |
def send_text_message(self, user_id, content):
"""
发送文本消息
详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html
:param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source
:param content: 消息正文
:return: 返回的 JSON 数据包
"""
return self.request.pos... |
def send_image_message(self, user_id, media_id):
"""
发送图片消息
详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html
:param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source
:param media_id: 图片的媒体ID。 可以通过 :func:`upload_media` 上传。
:return: 返回的 JSON 数据包
... |
def send_voice_message(self, user_id, media_id):
"""
发送语音消息
详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html
:param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source
:param media_id: 发送的语音的媒体ID。 可以通过 :func:`upload_media` 上传。
:return: 返回的 JSON 数据包
... |
def send_video_message(self, user_id, media_id, title=None, description=None):
"""
发送视频消息
详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html
:param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source
:param media_id: 发送的视频的媒体ID。 可以通过 :func:`upload_media` 上传。
... |
def send_article_message(self, user_id, articles=None, media_id=None):
"""
发送图文消息
详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html
:param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source
:param articles: list 对象, 每个元素为一个 dict 对象, key 包含 `title`, `descriptio... |
def create_qrcode(self, data):
"""
创建二维码
详情请参考 http://mp.weixin.qq.com/wiki/18/28fc21e7ed87bec960651f0ce873ef8a.html
:param data: 你要发送的参数 dict
:return: 返回的 JSON 数据包
"""
data = self._transcoding_dict(data)
return self.request.post(
url='https://... |
def set_template_industry(self, industry_id1, industry_id2):
"""
设置所属行业
详情请参考 http://mp.weixin.qq.com/wiki/17/304c1885ea66dbedf7dc170d84999a9d.html
:param industry_id1: 主营行业代码
:param industry_id2: 副营行业代码
:return: 返回的 JSON 数据包
"""
return self.request.post(
... |
def get_template_id(self, template_id_short):
"""
获得模板ID
详情请参考 http://mp.weixin.qq.com/wiki/17/304c1885ea66dbedf7dc170d84999a9d.html
:param template_id_short: 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
:return: 返回的 JSON 数据包
"""
return self.request.post(
url='ht... |
def send_template_message(self, user_id, template_id, data, url='', topcolor='#FF0000'):
"""
发送模版消息
详情请参考 http://mp.weixin.qq.com/wiki/17/304c1885ea66dbedf7dc170d84999a9d.html
:param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source (OpenID)
:param template_id: 模板ID
:param da... |
def _check_official_error(self, json_data):
"""
检测微信公众平台返回值中是否包含错误的返回码
:raises OfficialAPIError: 如果返回码提示有错误,抛出异常;否则返回 True
"""
if "errcode" in json_data and json_data["errcode"] != 0:
raise OfficialAPIError(errcode=json_data.get('errcode'), errmsg=json_data.get('errms... |
def request(self, method, url, access_token=None, **kwargs):
"""
向微信服务器发送请求
:param method: 请求方法
:param url: 请求地址
:param access_token: access token 值, 如果初始化时传入 conf 会自动获取, 如果没有传入则请提供此值
:param kwargs: 附加数据
:return: 微信服务器响应的 JSON 数据
"""
access_token =... |
def post(self, url, access_token=None, **kwargs):
"""
使用 POST 方法向微信服务器发出请求
:param url: 请求地址
:param access_token: access token 值, 如果初始化时传入 conf 会自动获取, 如果没有传入则请提供此值
:param kwargs: 附加数据
:return: 微信服务器响应的 JSON 数据
"""
return self.request(
method="po... |
def xml2dict(self):
"""
将 XML 转换为 dict
"""
self._remove_whitespace_nodes(self._doc.childNodes[0])
return self._element2dict(self._doc.childNodes[0]) |
def _element2dict(self, parent):
"""
将单个节点转换为 dict
"""
d = {}
for node in parent.childNodes:
if not isinstance(node, minidom.Element):
continue
if not node.hasChildNodes():
continue
if node.childNodes[0].nodeTyp... |
def _remove_whitespace_nodes(self, node, unlink=True):
"""
删除空白无用节点
"""
remove_list = []
for child in node.childNodes:
if child.nodeType == Node.TEXT_NODE and not child.data.strip():
remove_list.append(child)
elif child.hasChildNodes():
... |
def to_binary(value, encoding='utf-8'):
"""将 values 转为 bytes,默认编码 utf-8
:param value: 待转换的值
:param encoding: 编码
"""
if not value:
return b''
if isinstance(value, six.binary_type):
return value
if isinstance(value, six.text_type):
return value.encode(encoding)
if... |
def _transcoding(cls, data):
"""编码转换
:param data: 需要转换的数据
:return: 转换好的数据
"""
if not data:
return data
result = None
if isinstance(data, str) and hasattr(data, 'decode'):
result = data.decode('utf-8')
else:
result = dat... |
def _transcoding_list(cls, data):
"""编码转换 for list
:param data: 需要转换的 list 数据
:return: 转换好的 list
"""
if not isinstance(data, list):
raise ValueError('Parameter data must be list object.')
result = []
for item in data:
if isinstance(item, d... |
def _transcoding_dict(cls, data):
"""
编码转换 for dict
:param data: 需要转换的 dict 数据
:return: 转换好的 dict
"""
if not isinstance(data, dict):
raise ValueError('Parameter data must be dict object.')
result = {}
for k, v in data.items():
k = ... |
def encode(cls, text):
"""
对需要加密的明文进行填充补位
@param text: 需要进行填充补位操作的明文
@return: 补齐明文字符串
"""
text_length = len(text)
# 计算需要填充的位数
amount_to_pad = cls.block_size - (text_length % cls.block_size)
if amount_to_pad == 0:
amount_to_pad = cls.blo... |
def decode(cls, decrypted):
"""
删除解密后明文的补位字符
@param decrypted: 解密后的明文
@return: 删除补位字符后的明文
"""
pad = ord(decrypted[-1])
if pad < 1 or pad > 32:
pad = 0
return decrypted[:-pad] |
def decrypt(self, text, appid):
"""对解密后的明文进行补位删除
@param text: 密文
@return: 删除填充补位后的明文
"""
try:
cryptor = AES.new(self.key, self.mode, self.key[:16])
# 使用BASE64对密文进行解码,然后AES-CBC解密
plain_text = cryptor.decrypt(base64.b64decode(text))
exce... |
def get_random_str(self):
""" 随机生成16位字符串
@return: 16位字符串
"""
rule = string.ascii_letters + string.digits
return "".join(random.sample(rule, 16)) |
def _check_signature(self, msg_signature, timestamp, nonce, echostr):
"""验证签名有效性
:param msg_signature: 签名串,对应URL参数的msg_signature
:param timestamp: 时间戳,对应URL参数的timestamp
:param nonce: 随机串,对应URL参数的nonce
:param echostr: 随机串,对应URL参数的echostr
:return: 解密之后的echostr
:rai... |
def _encrypt_message(self, msg, nonce, timestamp=None):
"""将公众号回复用户的消息加密打包
:param msg: 待回复用户的消息,xml格式的字符串
:param nonce: 随机串,可以自己生成,也可以用URL参数的nonce
:param timestamp: 时间戳,可以自己生成,也可以用URL参数的timestamp,如为None则自动用当前时间
:return: 加密后的可以直接回复用户的密文,包括msg_signature, timestamp, nonce, encrypt的... |
def _decrypt_message(self, msg, msg_signature, timestamp, nonce):
"""检验消息的真实性,并且获取解密后的明文
:param msg: 密文,对应POST请求的数据
:param msg_signature: 签名串,对应URL参数的msg_signature
:param timestamp: 时间戳,对应URL参数的timestamp
:param nonce: 随机串,对应URL参数的nonce
:return: 解密后的原文
"""
... |
def Lastovka_Shaw(T, similarity_variable, cyclic_aliphatic=False):
r'''Calculate ideal-gas constant-pressure heat capacitiy with the similarity
variable concept and method as shown in [1]_.
.. math::
C_p^0 = \left(A_2 + \frac{A_1 - A_2}{1 + \exp(\frac{\alpha-A_3}{A_4})}\right)
+ (B_{11} + B... |
def Lastovka_Shaw_integral_over_T(T, similarity_variable, cyclic_aliphatic=False):
r'''Calculate the integral over temperature of ideal-gas constant-pressure
heat capacitiy with the similarity variable concept and method as shown in
[1]_.
Parameters
----------
T : float
Temperature of ... |
def TRCCp(T, a0, a1, a2, a3, a4, a5, a6, a7):
r'''Calculates ideal gas heat capacity using the model developed in [1]_.
The ideal gas heat capacity is given by:
.. math::
C_p = R\left(a_0 + (a_1/T^2) \exp(-a_2/T) + a_3 y^2
+ (a_4 - a_5/(T-a_7)^2 )y^j \right)
y = \frac{T-a_7}{T+a_6... |
def TRCCp_integral(T, a0, a1, a2, a3, a4, a5, a6, a7, I=0):
r'''Integrates ideal gas heat capacity using the model developed in [1]_.
Best used as a delta only.
The difference in enthalpy with respect to 0 K is given by:
.. math::
\frac{H(T) - H^{ref}}{RT} = a_0 + a_1x(a_2)/(a_2T) + I/T + h(T)... |
def TRCCp_integral_over_T(T, a0, a1, a2, a3, a4, a5, a6, a7, J=0):
r'''Integrates ideal gas heat capacity over T using the model developed in
[1]_. Best used as a delta only.
The difference in ideal-gas entropy with respect to 0 K is given by:
.. math::
\frac{S^\circ}{R} = J + a_0\ln T + \fra... |
def Rowlinson_Poling(T, Tc, omega, Cpgm):
r'''Calculate liquid constant-pressure heat capacitiy with the [1]_ CSP method.
This equation is not terrible accurate.
The heat capacity of a liquid is given by:
.. math::
\frac{Cp^{L} - Cp^{g}}{R} = 1.586 + \frac{0.49}{1-T_r} +
\omega\left[ ... |
def Rowlinson_Bondi(T, Tc, omega, Cpgm):
r'''Calculate liquid constant-pressure heat capacitiy with the CSP method
shown in [1]_.
The heat capacity of a liquid is given by:
.. math::
\frac{Cp^L - Cp^{ig}}{R} = 1.45 + 0.45(1-T_r)^{-1} + 0.25\omega
[17.11 + 25.2(1-T_r)^{1/3}T_r^{-1} + 1.... |
def Dadgostar_Shaw(T, similarity_variable):
r'''Calculate liquid constant-pressure heat capacitiy with the similarity
variable concept and method as shown in [1]_.
.. math::
C_{p} = 24.5(a_{11}\alpha + a_{12}\alpha^2)+ (a_{21}\alpha
+ a_{22}\alpha^2)T +(a_{31}\alpha + a_{32}\alpha^2)T^2
... |
def Dadgostar_Shaw_integral(T, similarity_variable):
r'''Calculate the integral of liquid constant-pressure heat capacitiy
with the similarity variable concept and method as shown in [1]_.
Parameters
----------
T : float
Temperature of gas [K]
similarity_variable : float
simila... |
def Dadgostar_Shaw_integral_over_T(T, similarity_variable):
r'''Calculate the integral of liquid constant-pressure heat capacitiy
with the similarity variable concept and method as shown in [1]_.
Parameters
----------
T : float
Temperature of gas [K]
similarity_variable : float
... |
def Zabransky_quasi_polynomial(T, Tc, a1, a2, a3, a4, a5, a6):
r'''Calculates liquid heat capacity using the model developed in [1]_.
.. math::
\frac{C}{R}=A_1\ln(1-T_r) + \frac{A_2}{1-T_r}
+ \sum_{j=0}^m A_{j+3} T_r^j
Parameters
----------
T : float
Temperature [K]
Tc ... |
def Zabransky_quasi_polynomial_integral(T, Tc, a1, a2, a3, a4, a5, a6):
r'''Calculates the integral of liquid heat capacity using the
quasi-polynomial model developed in [1]_.
Parameters
----------
T : float
Temperature [K]
a1-a6 : float
Coefficients
Returns
-------
... |
def Zabransky_quasi_polynomial_integral_over_T(T, Tc, a1, a2, a3, a4, a5, a6):
r'''Calculates the integral of liquid heat capacity over T using the
quasi-polynomial model developed in [1]_.
Parameters
----------
T : float
Temperature [K]
a1-a6 : float
Coefficients
Returns... |
def Zabransky_cubic(T, a1, a2, a3, a4):
r'''Calculates liquid heat capacity using the model developed in [1]_.
.. math::
\frac{C}{R}=\sum_{j=0}^3 A_{j+1} \left(\frac{T}{100}\right)^j
Parameters
----------
T : float
Temperature [K]
a1-a4 : float
Coefficients
Returns... |
def Zabransky_cubic_integral(T, a1, a2, a3, a4):
r'''Calculates the integral of liquid heat capacity using the model
developed in [1]_.
Parameters
----------
T : float
Temperature [K]
a1-a4 : float
Coefficients
Returns
-------
H : float
Difference in enthal... |
def Zabransky_cubic_integral_over_T(T, a1, a2, a3, a4):
r'''Calculates the integral of liquid heat capacity over T using the model
developed in [1]_.
Parameters
----------
T : float
Temperature [K]
a1-a4 : float
Coefficients
Returns
-------
S : float
Differ... |
def Lastovka_solid(T, similarity_variable):
r'''Calculate solid constant-pressure heat capacitiy with the similarity
variable concept and method as shown in [1]_.
.. math::
C_p = 3(A_1\alpha + A_2\alpha^2)R\left(\frac{\theta}{T}\right)^2
\frac{\exp(\theta/T)}{[\exp(\theta/T)-1]^2}
+... |
def Lastovka_solid_integral(T, similarity_variable):
r'''Integrates solid constant-pressure heat capacitiy with the similarity
variable concept and method as shown in [1]_.
Uses a explicit form as derived with Sympy.
Parameters
----------
T : float
Temperature of solid [K]
simi... |
def Lastovka_solid_integral_over_T(T, similarity_variable):
r'''Integrates over T solid constant-pressure heat capacitiy with the
similarity variable concept and method as shown in [1]_.
Uses a explicit form as derived with Sympy.
Parameters
----------
T : float
Temperature of sol... |
def load_all_methods(self):
r'''Method which picks out coefficients for the specified chemical
from the various dictionaries and DataFrames storing it. All data is
stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`,
and :obj:`all_methods` as a set of methods for which t... |
def calculate(self, T, method):
r'''Method to calculate surface tension of a liquid at temperature `T`
with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature at whi... |
def calculate_integral(self, T1, T2, method):
r'''Method to calculate the integral of a property with respect to
temperature, using a specified method. Implements the analytical
integrals of all available methods except for tabular data.
Parameters
----------
T1 ... |
def calculate_integral_over_T(self, T1, T2, method):
r'''Method to calculate the integral of a property over temperature
with respect to temperature, using a specified method. Implements the
analytical integrals of all available methods except for tabular data.
Parameters
... |
def calculate_integral(self, T1, T2):
r'''Method to compute the enthalpy integral of heat capacity from
`T1` to `T2`.
Parameters
----------
T1 : float
Initial temperature, [K]
T2 : float
Final temperature, [K]
Re... |
def calculate_integral_over_T(self, T1, T2):
r'''Method to compute the entropy integral of heat capacity from
`T1` to `T2`.
Parameters
----------
T1 : float
Initial temperature, [K]
T2 : float
Final temperature, [K]
... |
def add_coeffs(self, Tmin, Tmax, coeffs):
'''Called internally during the parsing of the Zabransky database, to
add coefficients as they are read one per line'''
self.n += 1
if not self.Ts:
self.Ts = [Tmin, Tmax]
self.coeff_sets = [coeffs]
else:
... |
def _coeff_ind_from_T(self, T):
'''Determines the index at which the coefficients for the current
temperature are stored in `coeff_sets`.
'''
# DO NOT CHANGE
if self.n == 1:
return 0
for i in range(self.n):
if T <= self.Ts[i+1]:
ret... |
def calculate(self, T):
r'''Method to actually calculate heat capacity as a function of
temperature.
Parameters
----------
T : float
Temperature, [K]
Returns
-------
Cp : float
Liquid heat capacity as T, [J/mol/K]
... |
def calculate_integral(self, T1, T2):
r'''Method to compute the enthalpy integral of heat capacity from
`T1` to `T2`. Analytically integrates across the piecewise spline
as necessary.
Parameters
----------
T1 : float
Initial temperature, [K]
... |
def calculate_integral_over_T(self, T1, T2):
r'''Method to compute the entropy integral of heat capacity from
`T1` to `T2`. Analytically integrates across the piecewise spline
as necessary.
Parameters
----------
T1 : float
Initial temperature, [K... |
def load_all_methods(self):
r'''Method which picks out coefficients for the specified chemical
from the various dictionaries and DataFrames storing it. All data is
stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`,
and :obj:`all_methods` as a set of methods for which t... |
def calculate(self, T, method):
r'''Method to calculate heat capacity of a liquid at temperature `T`
with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature at which... |
def calculate_integral(self, T1, T2, method):
r'''Method to calculate the integral of a property with respect to
temperature, using a specified method. Implements the
analytical integrals of all available methods except for tabular data,
the case of multiple coefficient sets needed to ... |
def calculate_integral_over_T(self, T1, T2, method):
r'''Method to calculate the integral of a property over temperature
with respect to temperature, using a specified method. Implements the
analytical integrals of all available methods except for tabular data,
the case of multiple co... |
def load_all_methods(self):
r'''Method which picks out coefficients for the specified chemical
from the various dictionaries and DataFrames storing it. All data is
stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`,
and :obj:`all_methods` as a set of methods for which t... |
def calculate(self, T, method):
r'''Method to calculate heat capacity of a solid at temperature `T`
with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature at which ... |
def calculate_integral(self, T1, T2, method):
r'''Method to calculate the integral of a property with respect to
temperature, using a specified method. Implements the analytical
integrals of all available methods except for tabular data.
Parameters
----------
T1 ... |
def calculate_integral_over_T(self, T1, T2, method):
r'''Method to calculate the integral of a property over temperature
with respect to temperature, using a specified method. Implements the
analytical integrals of all available methods except for tabular data.
Parameters
... |
def load_all_methods(self):
r'''Method to initialize the object by precomputing any values which
may be used repeatedly and by retrieving mixture-specific variables.
All data are stored as attributes. This method also sets :obj:`Tmin`,
:obj:`Tmax`, and :obj:`all_methods` as a set of met... |
def calculate(self, T, P, zs, ws, method):
r'''Method to calculate heat capacity of a liquid mixture at
temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
`ws` with a given method.
This method has no exception handling; see `mixture_property`
for that.
... |
def calculate(self, T, P, zs, ws, method):
r'''Method to calculate heat capacity of a solid mixture at
temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
`ws` with a given method.
This method has no exception handling; see `mixture_property`
for that.
... |
def calculate(self, T, P, zs, ws, method):
r'''Method to calculate heat capacity of a gas mixture at
temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
`ws` with a given method.
This method has no exception handling; see `mixture_property`
for that.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.