Commit 6cc3c82c authored by Theresa Pollinger's avatar Theresa Pollinger
Browse files

a bit more robust exastencils output, and investigations into omdoc output...

a bit more robust exastencils output, and investigations into omdoc output (does not work for pde description somehow)
parent 6d1e759f
......@@ -78,8 +78,8 @@ class ExaOutput:
l1path = str(self.filespath.with_suffix('.exa1'))
domain_name = utf8tolatex(simdata["domain"]["name"], non_ascii_only=True, brackets=False)
op = utf8tolatex(simdata["pdes"]["pdes"][-1]["op"], non_ascii_only=True, brackets=False)
bc_rhs = self.replace_boundary_x(simdata["bcs"]["bcs"][-1]["rhsstring_expanded"]) #TODO expand
pde_rhs = simdata["pdes"]["pdes"][-1]["rhsstring_expanded"]
bc_rhs = self.replace_cdot(self.replace_boundary_x(simdata["bcs"]["bcs"][-1]["rhsstring_expanded"])) #TODO expand
pde_rhs = self.replace_x(self.replace_cdot(simdata["pdes"]["pdes"][-1]["rhsstring_expanded"]))
unknowns = [*simdata["unknowns"]]
first_unknown = unknowns[0]
with open(l1path, 'w') as l1:
......@@ -136,7 +136,10 @@ class ExaOutput:
)
def replace_x(self, string):
return string.replace("x", "vf_nodePosition_x")
return string.replace("x", "vf_nodePosition_x@current")
def replace_cdot(self, string):
return string.replace("⋅", "*")
def replace_boundary_x(self, string):
return string.replace("x", "vf_boundaryCoord_x")
......
......@@ -46,8 +46,8 @@ class Interview(MetaKernel):
}
banner = \
"""**Hello, """ + getpass.getuser() + """! I am MoSIS, your partial differential equations and simulations expert.**
Let's set up a model and simulation together.
"""**Hello, """ + getpass.getuser() + """! I am MoSIS 1.0, your partial differential equations and simulations tool.**
Let's set up a model and simulation.
To get explanations, enter `explain <optional keyword>`.
To see a recap of what we know so far, enter `recap <optional keyword>`.
......@@ -93,7 +93,7 @@ Otherwise, you can always answer with \LaTeX-type input.
def do_execute_direct(self, code, silent=False, allow_stdin=True):
"""This is where the user input enters our code"""
arg = LatexNodes2Text().latex_to_text(code)
arg = string_handling.replace_times_to_cdot(LatexNodes2Text().latex_to_text(code))
if not self.keyword_handling(arg):
if not self.prompt_input_handling(arg):
......@@ -174,6 +174,9 @@ Otherwise, you can always answer with \LaTeX-type input.
if arg.startswith("widget"):
self.display_widget()
return True
if arg.startswith("omdoc"):
self.poutput(self.state_machine.mmtinterface.get_omdoc_theories())
return True
return False
# called when user types 'explain [expression]'
......
......@@ -204,6 +204,7 @@ class MMTInterface:
self.namespace = self.URIprefix + 'MitM/smglom/calculus/differentialequations' # TODO
self.debugprint = False
self.theories = []
def mmt_new_theory(self, thyname):
# So, ich hab mal was zu MMT/devel gepusht. Es gibt jetzt eine Extension namens InterviewServer. Starten tut man die mit "extension info.kwarc.mmt.interviews.InterviewServer"
......@@ -211,7 +212,10 @@ class MMTInterface:
# "http://localhost:8080/:interview/new?theory="<MMT URI>"" fügt eine neue theorie mit der uri <MMT URI> hinzu
req = '/' + self.mmt_extension + '/new?theory=' + quote(self.get_mpath(
thyname)) + '&meta=' + quote('http://mathhub.info/MitM/Foundation?Logic')
return self.http_request(req)
reply = self.http_request(req)
self.theories.append(thyname)
return reply
def mmt_new_view(self, viewname, fromtheory, totheory):
# analog für ?view="<MMT URI>".
......@@ -285,6 +289,12 @@ class MMTInterface:
return MMTReply(True, root)
return MMTReply(False, root)
def get_omdoc_theories(self):
string = ""
for theory in self.theories:
string += self.query_for(theory).tostring() + "\n\n"
return string
def add_dd(string):
if string.endswith("❙") or string.endswith("❚"):
......
......@@ -138,7 +138,7 @@ class PDE_States:
#"http://mathhub.info/MitM/smglom/calculus?higherderivative"]),
('parameters', ["http://mathhub.info/MitM/smglom/arithmetics?RealArithmetics", "ephdomain",
"http://mathhub.info/MitM/Foundation?Math"]),
('pdes', ["mDifferentialOperators"]), # +params, unknowns,
('pdes', ["mDifferentialOperators", "mFunctionArithmetics"]), # +params, unknowns,
('bcs',
["ephdomain", "mLinearity", "mDifferentialOperators",
"http://mathhub.info/MitM/smglom/arithmetics?RealArithmetics"]), # +params, unknowns, pdes, bctypes
......@@ -502,7 +502,7 @@ class PDE_States:
# TODO query number of effective pdes and unknowns from mmt for higher dimensional PDEs
# => can assume each to be ==1 for now
numpdesgiven = len(self.simdata["pdes"]["pdes"])
self.poutput("Ok, " + reply.tostring())
self.poutput("Ok, this is what this looks like in omdoc: " + reply.tostring())
if numpdesgiven == len(self.simdata["unknowns"]):
self.trigger('pdes_parsed')
elif numpdesgiven > len(self.simdata["unknowns"]):
......
......@@ -187,5 +187,14 @@ def add_ods(string):
def functionize(string, typename="Ω", varname="x"):
return string.replace("=", "= [ " + varname + " : " + typename + "]")
def split_string_at_AS(string):
return re.split('AS', string)
\ No newline at end of file
return re.split('AS', string)
def replace_times_to_cdot(string):
return string.replace("·", "⋅").replace("*", "⋅")
def replace_times_to_star(string):
return string.replace("·", "*").replace("⋅", "*")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment