├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── LICENSE
├── Makefile
├── README.rst
├── docs
├── Makefile
└── source
│ ├── conf.py
│ └── index.rst
├── flake.lock
├── flake.nix
├── papis_zotero
├── __init__.py
├── bibtex.py
├── server.py
├── sql.py
└── utils.py
├── pyproject.toml
├── tests
├── .gitkeep
├── __init__.py
├── resources
│ ├── bibtex
│ │ ├── files
│ │ │ ├── 8
│ │ │ │ └── Schaeffer - 2013 - Efficient spherical harmonic transforms aimed at p.pdf
│ │ │ ├── 10
│ │ │ │ └── De Lellis and Székelyhidi - 2009 - The Euler equations as a differential inclusion.pdf
│ │ │ ├── 12
│ │ │ │ └── Grubb - 2015 - Fractional Laplacians on domains, a development of.pdf
│ │ │ └── 15
│ │ │ │ └── Svärd and Nordström - 2014 - Review of summation-by-parts schemes for initial–b.pdf
│ │ └── zotero-library.bib
│ ├── bibtex_out.yaml
│ ├── sql
│ │ ├── storage
│ │ │ ├── 5KW7TMDH
│ │ │ │ ├── .zotero-ft-cache
│ │ │ │ ├── .zotero-ft-info
│ │ │ │ ├── .zotero-pdf-state
│ │ │ │ └── Schaeffer - 2013 - Efficient spherical harmonic transforms aimed at p.pdf
│ │ │ ├── J8FIHBUY
│ │ │ │ ├── .zotero-ft-cache
│ │ │ │ ├── .zotero-ft-info
│ │ │ │ ├── .zotero-pdf-state
│ │ │ │ └── Grubb - 2015 - Fractional Laplacians on domains, a development of.pdf
│ │ │ ├── PIMHYJGK
│ │ │ │ ├── .zotero-ft-cache
│ │ │ │ ├── .zotero-ft-info
│ │ │ │ ├── .zotero-pdf-state
│ │ │ │ └── De Lellis and Székelyhidi - 2009 - The Euler equations as a differential inclusion.pdf
│ │ │ └── WN7WJBGS
│ │ │ │ ├── .zotero-ft-cache
│ │ │ │ ├── .zotero-ft-info
│ │ │ │ ├── .zotero-pdf-state
│ │ │ │ └── Svärd and Nordström - 2014 - Review of summation-by-parts schemes for initial–b.pdf
│ │ └── zotero.sqlite
│ └── sql_out.yaml
├── test_bibtex.py
└── test_sql.py
└── tools
└── update-pypi.sh
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ "main" ]
7 | tags: [ 'v**' ]
8 | pull_request:
9 | branches: [ "main" ]
10 | schedule:
11 | # 17:00 on Friday (UTC)
12 | - cron: "00 17 * * 5"
13 |
14 | concurrency:
15 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16 | cancel-in-progress: true
17 |
18 | jobs:
19 | build:
20 | runs-on: ${{ matrix.os }}
21 | strategy:
22 | matrix:
23 | os: [ubuntu-latest, macos-latest, windows-latest]
24 | python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
25 | fail-fast: False
26 |
27 | steps:
28 | - uses: actions/checkout@v3
29 | - name: Set up Python ${{ matrix.python-version }}
30 | uses: actions/setup-python@v4
31 | with:
32 | python-version: ${{ matrix.python-version }}
33 |
34 | - name: Install dependencies
35 | run: |
36 | make ci-install
37 |
38 | - name: Lint with flake8
39 | run: |
40 | make flake8
41 |
42 | - name: Lint with mypy
43 | run: |
44 | make mypy
45 |
46 | - name: Test with pytest
47 | run: |
48 | make pytest
49 |
50 | pypi-release:
51 | needs: [build]
52 | name: PyPI Release
53 | environment: pypi
54 | permissions:
55 | contents: write
56 | id-token: write
57 | runs-on: ubuntu-latest
58 | steps:
59 | - uses: actions/checkout@v4
60 | with:
61 | fetch-depth: 0
62 |
63 | - uses: actions/setup-python@v5
64 | with:
65 | python-version: '3.12'
66 |
67 | - id: dist
68 | run: |
69 | make ci-install-build-system
70 | python -m build .
71 |
72 | - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
73 | name: Publish Package to PyPI
74 | uses: pypa/gh-action-pypi-publish@release/v1
75 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | doc/build/
2 | #Vim swap files
3 | *.swp
4 | *.swo
5 |
6 | # Byte-compiled / optimized / DLL files
7 | tags
8 | __pycache__/
9 | *.py[cod]
10 | *$py.class
11 |
12 | # C extensions
13 | *.so
14 |
15 | # Distribution / packaging
16 | .Python
17 | env/
18 | build/
19 | develop-eggs/
20 | dist/
21 | downloads/
22 | eggs/
23 | .eggs/
24 | lib/
25 | lib64/
26 | parts/
27 | sdist/
28 | var/
29 | *.egg-info/
30 | .installed.cfg
31 | *.egg
32 |
33 | # PyInstaller
34 | # Usually these files are written by a python script from a template
35 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
36 | *.manifest
37 | *.spec
38 |
39 | # Installer logs
40 | pip-log.txt
41 | pip-delete-this-directory.txt
42 |
43 | # Unit test / coverage reports
44 | htmlcov/
45 | .tox/
46 | .coverage
47 | .coverage.*
48 | .cache
49 | nosetests.xml
50 | coverage.xml
51 | *,cover
52 | .hypothesis/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # IPython Notebook
76 | .ipynb_checkpoints
77 |
78 | # pyenv
79 | .python-version
80 |
81 | # celery beat schedule file
82 | celerybeat-schedule
83 |
84 | # dotenv
85 | .env
86 |
87 | # virtualenv
88 | venv/
89 | ENV/
90 |
91 | # Spyder project settings
92 | .spyderproject
93 |
94 | # Rope project settings
95 | .ropeproject
96 | changes
97 | *~
98 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | all: help
2 |
3 | help: ## Show this help
4 | @echo -e "Specify a command. The choices are:\n"
5 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[0;36m%-18s\033[m %s\n", $$1, $$2}'
6 | @echo ""
7 | .PHONY: help
8 |
9 | tags: ## Generate ctags for main codebase
10 | ctags -f tags \
11 | --recurse=yes \
12 | --tag-relative=yes \
13 | --fields=+l \
14 | --kinds-python=-i \
15 | --language-force=python \
16 | papis_zotero
17 | .PHONY: tags
18 |
19 | flake8: ## Run flake8 checks
20 | python -m flake8 papis_zotero tests
21 | .PHONY: flake8
22 |
23 | mypy: ## Run (strict) mypy checks
24 | python -m mypy papis_zotero tests
25 | .PHONY: mypy
26 |
27 | pytest: ## Run pytest test and doctests
28 | python -m pytest -rswx -v -s tests
29 | .PHONY: pytest
30 |
31 | ci-install-build-system:
32 | python -m pip install --upgrade pip hatchling wheel build
33 | .PHONY: ci-install-build-system
34 |
35 | ci-install: ci-install-build-system ## Run pip and install dependencies on CI
36 | python -m pip install -e '.[develop]'
37 | .PHONY: ci-install
38 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | |pypi| |ci|
2 |
3 | Zotero compatibility for Papis
4 | ==============================
5 |
6 | Installation
7 | ------------
8 |
9 | Pip
10 | ^^^
11 |
12 | To install the latest release from PyPI
13 |
14 | .. code:: bash
15 |
16 | python -m pip install papis-zotero
17 |
18 | To install the latest development version
19 |
20 | .. code:: bash
21 |
22 | python -m pip install papis-zotero@https://github.com/papis/papis-zotero.git#egg=papis-zotero
23 |
24 | Nix
25 | ^^^
26 |
27 | For Nix and NixOS users, a Nix flake is included in this repository and can be
28 | used to install the package. There are many ways of doing so, for instance like so:
29 |
30 | .. code:: nix
31 |
32 | {
33 | pkgs,
34 | inputs,
35 | ...
36 | }: {
37 | home.packages = with pkgs; [
38 | (
39 | python3.withPackages
40 | (
41 | ps: [
42 | inputs.papis.packages.${system}.default
43 | inputs.papis-zotero.packages.${system}.default
44 | # you can add other packages you might want to make available for papis
45 | # ps.jinja2
46 | ]
47 | )
48 | )
49 | # Here you can list other packages, such as
50 | # typst
51 | # hayagriva
52 | # zotero_7
53 | ];
54 | }
55 |
56 | Arch
57 | ^^^^
58 |
59 | Arch users can use the AUR to install `the package
60 | `__.
61 |
62 | Importing from Zotero SQLite (preferred)
63 | ----------------------------------------
64 |
65 | Zotero also maintains a database of all its files and collections under a
66 | ``zotero.sqlite`` file. You can check where this file is located by going to
67 | ``Edit > Preferences > Advanced > Data Directory Location`` (may vary depending
68 | on the Zotero version). The Zotero data directory should contain the ``zotero.sqlite``
69 | file and a ``storage`` directory with the files for each document.
70 |
71 | The SQLite database maintained by Zotero can be imported directly (without
72 | using a BibTeX export) by ``papis-zotero``. This can be done with:
73 |
74 | .. code:: bash
75 |
76 | papis zotero import --from-sql-folder
77 |
78 | Here, ``ZOTERO_DATA_DIRECTORY`` is the folder containing the ``zotero.sqlite``
79 | file. By default, ``papis-zotero`` will add the imported documents to your
80 | current library directory, but it can be customized using the
81 | ``--outfolder`` argument.
82 |
83 | Importing from BibTeX (alternative)
84 | -----------------------------------
85 |
86 | Zotero can export different variants of BibTeX or BibLaTeX files
87 | (from ``Files > Export Library``). You could import the resulting ``.bib`` file
88 | directly with Papis (with the ``papis bibtex`` command), but ``papis-zotero``
89 | provides a specialised command. This command has better support for special Zotero
90 | fields. To import a given exported library run:
91 |
92 | .. code:: bash
93 |
94 | papis zotero import --from-bibtex library.bib
95 |
96 | BibTeX files exported by Zotero can include attached files as shown in the below
97 | example:
98 |
99 | .. code:: bibtex
100 |
101 | @article{Einstein1905Photon,
102 | author = { A. Einstein },
103 | doi = { 10.1002/andp.19053220607 },
104 | journal = { Ann. Phys. },
105 | pages = { 132--148 },
106 | title = { Über einen die Erzeugung und Verwandlung des Lichtes
107 | betreffenden heuristischen Gesichtspunkt },
108 | file = { Full Text:path/to/some/relative/file.pdf },
109 | volume = { 322 },
110 | year = { 1905 },
111 | }
112 |
113 | Given this, ``papis-zotero`` will interpret the path of the ``file`` entry
114 | as a relative path to the ``library.bib`` passed to the import command using
115 | ``--from-bibtex``. The files are skipped if they do not exist at the expected
116 | location.
117 |
118 | By default, ``papis-zotero`` will add the documents to your current library.
119 | When initially importing a big library, it is recommended to always import it
120 | into a scratch folder, so that you can verify the import. This can be easily done
121 | using:
122 |
123 | .. code:: bash
124 |
125 | papis zotero import --from-bibtex library.bib --outfolder some/folder/lib
126 |
127 | When you are ready you can move this folder to a final Papis library.
128 |
129 | Using Zotero connectors
130 | -----------------------
131 |
132 | This plugin can also connect to a Zotero connector browser plugin. First, such
133 | a plugin should be installed from the
134 | `Zotero website `__. Then, make sure that
135 | Zotero itself is not running (and connected to the connector) and run:
136 |
137 | .. code:: bash
138 |
139 | papis zotero serve
140 |
141 | Papis now starts listening to your browser for incoming data. Whenever you click the
142 | Zotero button to add a paper, ``papis-zotero`` will add this paper to the Papis
143 | library instead.
144 |
145 | Development
146 | -----------
147 |
148 | This project uses ``pyproject.toml`` and ``hatchling`` for its build system.
149 | To develop the code, it is recommended to start up a
150 | `virtual environment `__ and
151 | install the project in editable mode using, e.g.::
152 |
153 | python -m pip install -e '.[develop]'
154 |
155 | After installation, always check that the command is correctly recognized, e.g.
156 | by looking at the help output
157 |
158 | .. code:: bash
159 |
160 | papis zotero --help
161 |
162 | If you use the Nix flake, you can also use the included ``devShell`` with
163 | ``nix develop``.
164 |
165 |
166 | .. |pypi| image:: https://badge.fury.io/py/papis-zotero.svg
167 | :target: https://badge.fury.io/py/papis-zotero
168 | .. |ci| image:: https://github.com/papis/papis-zotero/workflows/CI/badge.svg
169 | :target: https://github.com/papis/papis-zotero/actions?query=branch%3Amain+workflow%3ACI
170 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SPHINXPROJ = PapisZotero
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
--------------------------------------------------------------------------------
/docs/source/conf.py:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration file for the Sphinx documentation builder.
3 | #
4 | # This file does only contain a selection of the most common options. For a
5 | # full list see the documentation:
6 | # http://www.sphinx-doc.org/en/stable/config
7 |
8 | # -- Path setup --------------------------------------------------------------
9 |
10 | # If extensions (or modules to document with autodoc) are in another directory,
11 | # add these directories to sys.path here. If the directory is relative to the
12 | # documentation root, use os.path.abspath to make it absolute, like shown here.
13 | #
14 | # import os
15 | # import sys
16 | # sys.path.insert(0, os.path.abspath('.'))
17 |
18 | # -- Project information -----------------------------------------------------
19 |
20 | project = "Papis Zotero"
21 | copyright = "2019, Papis community"
22 | author = "Papis community"
23 |
24 | # The short X.Y version
25 | version = ""
26 | # The full version, including alpha/beta/rc tags
27 | release = ""
28 |
29 | # -- General configuration ---------------------------------------------------
30 |
31 | # If your documentation needs a minimal Sphinx version, state it here.
32 | #
33 | # needs_sphinx = '1.0'
34 |
35 | # Add any Sphinx extension module names here, as strings. They can be
36 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
37 | # ones.
38 | extensions = [
39 | "sphinx.ext.autodoc",
40 | "sphinx.ext.doctest",
41 | "sphinx.ext.todo",
42 | "sphinx.ext.coverage",
43 | "sphinx.ext.ifconfig",
44 | "sphinx.ext.viewcode",
45 | "sphinx_click.ext",
46 | ]
47 |
48 | # Add any paths that contain templates here, relative to this directory.
49 | templates_path = ["_templates"]
50 |
51 | # The suffix(es) of source filenames.
52 | # You can specify multiple suffix as a list of string:
53 | #
54 | # source_suffix = ['.rst', '.md']
55 | source_suffix = ".rst"
56 |
57 | # The master toctree document.
58 | master_doc = "index"
59 |
60 | # The language for content autogenerated by Sphinx. Refer to documentation
61 | # for a list of supported languages.
62 | #
63 | # This is also used if you do content translation via gettext catalogs.
64 | # Usually you set "language" from the command line for these cases.
65 | # language = None
66 |
67 | # List of patterns, relative to source directory, that match files and
68 | # directories to ignore when looking for source files.
69 | # This pattern also affects html_static_path and html_extra_path .
70 | exclude_patterns = []
71 |
72 | # The name of the Pygments (syntax highlighting) style to use.
73 | pygments_style = "sphinx"
74 |
75 | # -- Options for HTML output -------------------------------------------------
76 |
77 | # The theme to use for HTML and HTML Help pages. See the documentation for
78 | # a list of builtin themes.
79 | #
80 | html_theme = "sphinx_rtd_theme"
81 |
82 | # Theme options are theme-specific and customize the look and feel of a theme
83 | # further. For a list of options available for each theme, see the
84 | # documentation.
85 | #
86 | # html_theme_options = {}
87 |
88 | # Add any paths that contain custom static files (such as style sheets) here,
89 | # relative to this directory. They are copied after the builtin static files,
90 | # so a file named "default.css" will overwrite the builtin "default.css".
91 | # html_static_path = ["_static"]
92 |
93 | # Custom sidebar templates, must be a dictionary that maps document names
94 | # to template names.
95 | #
96 | # The default sidebars (for documents that don't match any pattern) are
97 | # defined by theme itself. Builtin themes are using these templates by
98 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
99 | # 'searchbox.html']``.
100 | #
101 | # html_sidebars = {}
102 |
103 | # -- Options for HTMLHelp output ---------------------------------------------
104 |
105 | # Output file base name for HTML help builder.
106 | htmlhelp_basename = "papiszoterodoc"
107 |
108 | # -- Options for LaTeX output ------------------------------------------------
109 |
110 | latex_elements = {
111 | # The paper size ('letterpaper' or 'a4paper').
112 | #
113 | # 'papersize': 'letterpaper',
114 |
115 | # The font size ('10pt', '11pt' or '12pt').
116 | #
117 | # 'pointsize': '10pt',
118 |
119 | # Additional stuff for the LaTeX preamble.
120 | #
121 | # 'preamble': '',
122 |
123 | # Latex figure (float) alignment
124 | #
125 | # 'figure_align': 'htbp',
126 | }
127 |
128 | # Grouping the document tree into LaTeX files. List of tuples
129 | # (source start file, target name, title,
130 | # author, documentclass [howto, manual, or own class]).
131 | latex_documents = [
132 | (master_doc, "PapisZotero.tex", "Papis Zotero Documentation",
133 | "Papis community", "manual"),
134 | ]
135 |
136 | # -- Options for manual page output ------------------------------------------
137 |
138 | # One entry per manual page. List of tuples
139 | # (source start file, name, description, authors, manual section).
140 | man_pages = [
141 | (master_doc, "papiszotero", "Papis Zotero Documentation",
142 | [author], 1)
143 | ]
144 |
145 | # -- Options for Texinfo output ----------------------------------------------
146 |
147 | # Grouping the document tree into Texinfo files. List of tuples
148 | # (source start file, target name, title, author,
149 | # dir menu entry, description, category)
150 | texinfo_documents = [
151 | (master_doc, "PapisZotero", "Papis Zotero Documentation",
152 | author, "PapisZotero", "One line description of project.",
153 | "Miscellaneous"),
154 | ]
155 |
156 | # -- Extension configuration -------------------------------------------------
157 |
158 | # -- Options for todo extension ----------------------------------------------
159 |
160 | # If true, `todo` and `todoList` produce output, else they produce nothing.
161 | todo_include_todos = True
162 |
--------------------------------------------------------------------------------
/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | Welcome to Papis Zotero's documentation!
2 | ========================================
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 | :caption: Contents:
7 |
8 | Command-line interface
9 | ----------------------
10 |
11 | .. click:: papis_zotero:main
12 | :prog: papis zotero
13 |
14 | .. click:: papis_zotero:serve
15 | :prog: papis zotero serve
16 |
17 | .. click:: papis_zotero:do_importer
18 | :prog: papis zotero import
19 |
20 | Indices and tables
21 | ==================
22 |
23 | * :ref:`genindex`
24 | * :ref:`modindex`
25 | * :ref:`search`
26 |
--------------------------------------------------------------------------------
/flake.lock:
--------------------------------------------------------------------------------
1 | {
2 | "nodes": {
3 | "flake-utils": {
4 | "inputs": {
5 | "systems": "systems"
6 | },
7 | "locked": {
8 | "lastModified": 1731533236,
9 | "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
10 | "owner": "numtide",
11 | "repo": "flake-utils",
12 | "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
13 | "type": "github"
14 | },
15 | "original": {
16 | "owner": "numtide",
17 | "repo": "flake-utils",
18 | "type": "github"
19 | }
20 | },
21 | "flake-utils_2": {
22 | "inputs": {
23 | "systems": "systems_2"
24 | },
25 | "locked": {
26 | "lastModified": 1731533236,
27 | "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
28 | "owner": "numtide",
29 | "repo": "flake-utils",
30 | "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
31 | "type": "github"
32 | },
33 | "original": {
34 | "owner": "numtide",
35 | "repo": "flake-utils",
36 | "type": "github"
37 | }
38 | },
39 | "nixpkgs": {
40 | "locked": {
41 | "lastModified": 1744463964,
42 | "narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
43 | "owner": "nixos",
44 | "repo": "nixpkgs",
45 | "rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
46 | "type": "github"
47 | },
48 | "original": {
49 | "owner": "nixos",
50 | "ref": "nixos-unstable",
51 | "repo": "nixpkgs",
52 | "type": "github"
53 | }
54 | },
55 | "papis": {
56 | "inputs": {
57 | "flake-utils": "flake-utils_2",
58 | "nixpkgs": [
59 | "nixpkgs"
60 | ],
61 | "pyproject-nix": "pyproject-nix"
62 | },
63 | "locked": {
64 | "lastModified": 1743954027,
65 | "narHash": "sha256-s0MtTSuVP4MBpLO2U9TlGuEI3R8goCjlKnmqo9wIPRM=",
66 | "owner": "papis",
67 | "repo": "papis",
68 | "rev": "9cffc6e4eb616402d8e28689a633764088850e26",
69 | "type": "github"
70 | },
71 | "original": {
72 | "owner": "papis",
73 | "repo": "papis",
74 | "type": "github"
75 | }
76 | },
77 | "pyproject-nix": {
78 | "inputs": {
79 | "nixpkgs": [
80 | "papis",
81 | "nixpkgs"
82 | ]
83 | },
84 | "locked": {
85 | "lastModified": 1741648141,
86 | "narHash": "sha256-jQEZCSCgm60NGmBg3JPu290DDhNVI1GVVEd0P8VCnME=",
87 | "owner": "nix-community",
88 | "repo": "pyproject.nix",
89 | "rev": "7747e5a058245c7abe033a798f818f0572d8e155",
90 | "type": "github"
91 | },
92 | "original": {
93 | "owner": "nix-community",
94 | "repo": "pyproject.nix",
95 | "type": "github"
96 | }
97 | },
98 | "pyproject-nix_2": {
99 | "inputs": {
100 | "nixpkgs": [
101 | "nixpkgs"
102 | ]
103 | },
104 | "locked": {
105 | "lastModified": 1743438845,
106 | "narHash": "sha256-1GSaoubGtvsLRwoYwHjeKYq40tLwvuFFVhGrG8J9Oek=",
107 | "owner": "nix-community",
108 | "repo": "pyproject.nix",
109 | "rev": "8063ec98edc459571d042a640b1c5e334ecfca1e",
110 | "type": "github"
111 | },
112 | "original": {
113 | "owner": "nix-community",
114 | "repo": "pyproject.nix",
115 | "type": "github"
116 | }
117 | },
118 | "root": {
119 | "inputs": {
120 | "flake-utils": "flake-utils",
121 | "nixpkgs": "nixpkgs",
122 | "papis": "papis",
123 | "pyproject-nix": "pyproject-nix_2"
124 | }
125 | },
126 | "systems": {
127 | "locked": {
128 | "lastModified": 1681028828,
129 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
130 | "owner": "nix-systems",
131 | "repo": "default",
132 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
133 | "type": "github"
134 | },
135 | "original": {
136 | "owner": "nix-systems",
137 | "repo": "default",
138 | "type": "github"
139 | }
140 | },
141 | "systems_2": {
142 | "locked": {
143 | "lastModified": 1681028828,
144 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
145 | "owner": "nix-systems",
146 | "repo": "default",
147 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
148 | "type": "github"
149 | },
150 | "original": {
151 | "owner": "nix-systems",
152 | "repo": "default",
153 | "type": "github"
154 | }
155 | }
156 | },
157 | "root": "root",
158 | "version": 7
159 | }
160 |
--------------------------------------------------------------------------------
/flake.nix:
--------------------------------------------------------------------------------
1 | {
2 | description = "Zotero compatibility layer for Papis";
3 |
4 | inputs = {
5 | nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
6 | papis = {
7 | url = "github:papis/papis";
8 | inputs.nixpkgs.follows = "nixpkgs";
9 | };
10 | pyproject-nix = {
11 | url = "github:nix-community/pyproject.nix";
12 | inputs.nixpkgs.follows = "nixpkgs";
13 | };
14 | flake-utils.url = "github:numtide/flake-utils";
15 | };
16 |
17 | outputs = {
18 | self,
19 | nixpkgs,
20 | flake-utils,
21 | pyproject-nix,
22 | papis,
23 | }:
24 | flake-utils.lib.eachDefaultSystem (
25 | system: let
26 | pypkgs = pkgs.python3Packages;
27 | pkgs = nixpkgs.legacyPackages.${system};
28 | python = pkgs.python3.override {
29 | packageOverrides = self: super: {
30 | papis = papis.packages.${system}.default;
31 | flake8-quotes = flake8-quotes;
32 | flake8-pyproject = flake8-pyproject;
33 | python-coveralls = python-coveralls;
34 | };
35 | };
36 | project = pyproject-nix.lib.project.loadPyproject {projectRoot = ./.;};
37 |
38 | flake8-quotes = python.pkgs.buildPythonPackage rec {
39 | pname = "flake8-quotes";
40 | version = "3.4.0";
41 |
42 | src = python.pkgs.fetchPypi {
43 | inherit pname version;
44 | sha256 = "sha256-qthJL7cQotPqvmjF+GoUKN5lDISEEn4UxD0FBLowJ2w=";
45 | };
46 |
47 | doCheck = false;
48 | checkInputs = [];
49 |
50 | meta = with pkgs.lib; {
51 | homepage = "http://github.com/zheller/flake8-quotes";
52 | description = "Flake8 lint for quotes.";
53 | license = licenses.mit;
54 | };
55 | };
56 |
57 | flake8-pyproject = python.pkgs.buildPythonPackage {
58 | pname = "flake8-pyproject";
59 | version = "1.2.3";
60 | pyproject = true;
61 |
62 | src = pkgs.fetchFromGitHub {
63 | owner = "john-hen";
64 | repo = "Flake8-pyproject";
65 | rev = "30b8444781d16edd54c11df08210a7c8fb79258d";
66 | hash = "sha256-bPRIj7tYmm6I9eo1ZjiibmpVmGcHctZSuTvnKX+raPg=";
67 | };
68 |
69 | doCheck = false;
70 | checkInputs = [];
71 | propagatedBuildInputs = [pypkgs.flit-core pypkgs.flake8];
72 |
73 | meta = with pkgs.lib; {
74 | homepage = "https://github.com/john-hen/Flake8-pyproject";
75 | description = "Flake8 plug-in loading the configuration from pyproject.toml";
76 | license = licenses.mit;
77 | };
78 | };
79 |
80 | python-coveralls = python.pkgs.buildPythonPackage rec {
81 | pname = "python-coveralls";
82 | version = "2.9.3";
83 |
84 | src = python.pkgs.fetchPypi {
85 | inherit pname version;
86 | sha256 = "sha256-v694EefcVijoO2sWKWKk4khdv/GEsw5J84A3TtG87lU=";
87 | };
88 |
89 | doCheck = false;
90 | checkInputs = [];
91 |
92 | meta = with pkgs.lib; {
93 | homepage = "http://github.com/z4r/python-coveralls";
94 | description = "Python interface to coveralls.io API ";
95 | license = licenses.asl20;
96 | };
97 | };
98 | in {
99 | packages = {
100 | papis-zotero = let
101 | attrs = project.renderers.buildPythonPackage {
102 | inherit python;
103 | };
104 | in
105 | python.pkgs.buildPythonPackage (attrs
106 | // {
107 | version =
108 | if (self ? rev)
109 | then self.shortRev
110 | else self.dirtyShortRev;
111 | propagatedBuildInputs = [
112 | papis.packages.${system}.default
113 | ];
114 | });
115 | default = self.packages.${system}.papis-zotero;
116 | };
117 |
118 | devShells = {
119 | default = let
120 | arg = project.renderers.withPackages {
121 | inherit python;
122 | extras = ["develop"];
123 | };
124 | pythonEnv = python.withPackages arg;
125 | in
126 | pkgs.mkShell {
127 | packages = [
128 | pythonEnv
129 | self.packages.${system}.papis-zotero
130 | ];
131 | shellHook = ''
132 | export PYTHONPATH="$(pwd):$PYTHONPATH"
133 | '';
134 | };
135 | };
136 | }
137 | );
138 | }
139 |
--------------------------------------------------------------------------------
/papis_zotero/__init__.py:
--------------------------------------------------------------------------------
1 | from functools import partial
2 | import os
3 | import http.server
4 | from typing import List, Optional, Tuple
5 |
6 | import click
7 |
8 | import papis.config
9 | import papis.logging
10 | import papis_zotero.server
11 |
12 | logger = papis.logging.get_logger(__name__)
13 |
14 |
15 | @click.group("zotero")
16 | @click.help_option("-h", "--help")
17 | def main() -> None:
18 | """Zotero interface for papis."""
19 |
20 |
21 | @main.command("serve")
22 | @click.help_option("-h", "--help")
23 | @click.option("--port",
24 | help="Port to listen to",
25 | default=papis_zotero.server.ZOTERO_PORT,
26 | type=int)
27 | @click.option("--address", help="Address to bind", default="localhost")
28 | @click.option(
29 | "-s", "--set", "set_list",
30 | help="Set imported document metadata as . Can be used multiple times.",
31 | multiple=True,
32 | type=(str, str))
33 | def serve(address: str, port: int, set_list: List[Tuple[str, str]],) -> None:
34 | """Start a ``zotero-connector`` server."""
35 |
36 | logger.warning("The 'zotero-connector' server is experimental. "
37 | "Please report bugs and improvements at "
38 | "https://github.com/papis/papis-zotero/issues.")
39 |
40 | server_address = (address, port)
41 | request_handler = partial(papis_zotero.server.PapisRequestHandler, set_list)
42 | try:
43 | httpd = http.server.HTTPServer(server_address, request_handler)
44 | except OSError:
45 | logger.error(
46 | "Address '%s:%s' is already in use. This may be because you "
47 | "have the Zotero application open.", address, port)
48 | logger.error("papis zotero serve requires to be the only one "
49 | "listening on that port. Zotero must quit before this "
50 | "command can be used!")
51 | return
52 |
53 | logger.info("Starting server in address https://%s:%s.", address, port)
54 | logger.info("Press Ctrl-C to exit.")
55 |
56 | httpd.serve_forever()
57 |
58 |
59 | @main.command("import")
60 | @click.help_option("-h", "--help")
61 | @click.option(
62 | "-f",
63 | "--from-bibtex",
64 | "from_bibtex",
65 | help="Import Zotero library from a BibTeX dump, the files fields in "
66 | "the BibTeX files should point to valid paths",
67 | default=None,
68 | type=click.Path(exists=True))
69 | @click.option("-s",
70 | "--from-sql",
71 | "--from-sql-folder",
72 | "from_sql",
73 | help="Path to the FOLDER where the 'zotero.sqlite' file resides",
74 | default=None,
75 | type=click.Path(exists=True))
76 | @click.option("-o",
77 | "--outfolder",
78 | help="Folder to save the imported library",
79 | default=None,
80 | type=str)
81 | @click.option("--link",
82 | help="Whether to link the pdf files or copy them",
83 | is_flag=True,
84 | default=False)
85 | def do_importer(from_bibtex: Optional[str], from_sql: Optional[str],
86 | outfolder: Optional[str], link: bool) -> None:
87 | """Import zotero libraries into papis libraries."""
88 | import papis_zotero.bibtex
89 | import papis_zotero.sql
90 |
91 | if outfolder is None:
92 | outfolder = papis.config.get_lib_dirs()[0]
93 |
94 | if not os.path.exists(outfolder):
95 | os.makedirs(outfolder)
96 |
97 | if from_bibtex is not None:
98 | import papis_zotero.bibtex
99 | papis_zotero.bibtex.add_from_bibtex(from_bibtex, outfolder, link)
100 | elif from_sql is not None:
101 | import papis_zotero.sql
102 | try:
103 | papis_zotero.sql.add_from_sql(from_sql, outfolder, link)
104 | except Exception as exc:
105 | logger.error("Failed to import from file: %s",
106 | from_sql,
107 | exc_info=exc)
108 | else:
109 | logger.error("Either '--from-bibtex' or '--from-sql-folder' should be "
110 | "passed to import from Zotero.")
111 |
--------------------------------------------------------------------------------
/papis_zotero/bibtex.py:
--------------------------------------------------------------------------------
1 | import os
2 | import re
3 | from typing import Any, Dict, Optional
4 |
5 | import papis.bibtex
6 | import papis.commands.add
7 | import papis.config
8 | import papis.logging
9 |
10 | logger = papis.logging.get_logger(__name__)
11 |
12 | RE_SEPARATOR = re.compile(r"\s*,\s*")
13 |
14 |
15 | def add_from_bibtex(bib_file: str,
16 | out_folder: Optional[str] = None,
17 | link: bool = False) -> None:
18 | if out_folder is not None:
19 | papis.config.set_lib_from_name(out_folder)
20 |
21 | entries = papis.bibtex.bibtex_to_dict(bib_file)
22 | nentries = len(entries)
23 | for i, entry in enumerate(entries):
24 | result: Dict[str, Any] = entry.copy()
25 |
26 | # cleanup date
27 | if "date" in result:
28 | date = str(result.pop("date")).split("-")
29 | result["year"] = int(date[0])
30 | result["month"] = int(date[1])
31 |
32 | # cleanup tags
33 | if "keywords" in result:
34 | result["tags"] = RE_SEPARATOR.split(result.pop("keywords"))
35 |
36 | if "ref" in result:
37 | result["ref"] = papis.bibtex.ref_cleanup(result["ref"])
38 | else:
39 | result["ref"] = papis.bibtex.create_reference(result)
40 |
41 | # get file
42 | pdf_file = result.pop("file", None)
43 | if pdf_file is not None:
44 | pdf_file = pdf_file.split(":")[1]
45 | pdf_file = os.path.join(*pdf_file.split("/"))
46 | pdf_file = os.path.join(os.path.dirname(bib_file), pdf_file)
47 |
48 | if os.path.exists(pdf_file):
49 | logger.info("Document file found: '%s'.", pdf_file)
50 | else:
51 | logger.warning("Document file not found: '%s'.", pdf_file)
52 | pdf_file = None
53 |
54 | # add to library
55 | logger.info("[%4d/%-4d] Exporting item with ref '%s'.",
56 | i, nentries, result["ref"])
57 |
58 | papis.commands.add.run([pdf_file] if pdf_file is not None else [],
59 | data=result,
60 | link=link)
61 |
--------------------------------------------------------------------------------
/papis_zotero/server.py:
--------------------------------------------------------------------------------
1 | """Start a web server listening on port 23119. This server is
2 | compatible with the `zotero connector`. This means that if zotero is
3 | *not* running, you can have items from your web browser added directly
4 | into papis.
5 |
6 | """
7 |
8 | import json
9 | import http.server
10 | from typing import Any, Dict, List, Tuple
11 |
12 | import papis.api
13 | import papis.crossref
14 | import papis.document
15 | import papis.commands.add
16 | import papis.logging
17 |
18 | import papis_zotero.utils
19 |
20 | logger = papis.logging.get_logger(__name__)
21 |
22 | # NOTE: 5.0.75 was released in October 8, 2019 at the same time with Python 3.8
23 | ZOTERO_CONNECTOR_API_VERSION = 2
24 | ZOTERO_VERSION = "5.0.75"
25 | ZOTERO_PORT = 23119
26 |
27 | _k = papis.document.KeyConversionPair
28 |
29 | ZOTERO_TO_PAPIS_CONVERSIONS = [
30 | _k("creators", [{
31 | "key": "author_list",
32 | "action": lambda a: zotero_authors(a)
33 | }]),
34 | _k("tags", [{
35 | "key": "tags",
36 | "action": lambda t: [tag["tag"] for tag in t]
37 | }]),
38 | _k("date", [
39 | {"key": "year", "action": lambda d: int(d.split("-")[0])},
40 | {"key": "month", "action": lambda d: int(d.split("-")[1])},
41 | ]),
42 | _k("archiveID", [
43 | {"key": "eprint", "action": lambda a: a.split(":")[-1]}
44 | ]),
45 | _k("type", [
46 | {"key": "type", "action": papis_zotero.utils.ZOTERO_TO_PAPIS_TYPES.get}
47 | ]),
48 | ]
49 |
50 |
51 | def zotero_authors(creators: List[Dict[str, str]]) -> List[Dict[str, str]]:
52 | authors = []
53 | for creator in creators:
54 | if creator["creatorType"] != "author":
55 | continue
56 |
57 | authors.append({
58 | "given": creator["firstName"],
59 | "family": creator["lastName"],
60 | })
61 |
62 | return authors
63 |
64 |
65 | def zotero_data_to_papis_data(item: Dict[str, Any]) -> Dict[str, Any]:
66 | item.pop("id", None)
67 | item.pop("attachments", None)
68 | item.pop("html", None)
69 | item.pop("detailedCookies", None)
70 | item.pop("uri", None)
71 | item.pop("sessionID", None)
72 |
73 | if item.get("referrer") == "":
74 | item.pop("referrer", None)
75 |
76 | for foreign_key, key in papis_zotero.utils.ZOTERO_TO_PAPIS_FIELDS.items():
77 | if foreign_key in item:
78 | item[key] = item.pop(foreign_key)
79 |
80 | item = papis.document.keyconversion_to_data(ZOTERO_TO_PAPIS_CONVERSIONS,
81 | item,
82 | keep_unknown_keys=True)
83 | for key in papis_zotero.utils.ZOTERO_EXCLUDED_FIELDS:
84 | if key in item:
85 | del item[key]
86 |
87 | # try to get information from Crossref as well
88 | if "doi" in item:
89 | try:
90 | crossref_data = papis.crossref.doi_to_data(item["doi"])
91 | crossref_data.pop("title", None)
92 | logger.info("Updating document with data from Crossref.")
93 | except ValueError:
94 | crossref_data = {}
95 |
96 | item.update(crossref_data)
97 |
98 | logger.info("Document metadata: %s", item)
99 | return item
100 |
101 |
102 | def download_zotero_attachments(attachments: List[Dict[str, str]]) -> List[str]:
103 | files = []
104 |
105 | for attachment in attachments:
106 | logger.info("Checking attachment: %s", attachment)
107 |
108 | mime = str(attachment.get("mimeType"))
109 | if mime not in papis_zotero.utils.ZOTERO_SUPPORTED_MIMETYPES_TO_EXTENSION:
110 | continue
111 |
112 | url = attachment["url"]
113 | extension = papis_zotero.utils.ZOTERO_SUPPORTED_MIMETYPES_TO_EXTENSION[mime]
114 | logger.info("Downloading file (%s): '%s'.", mime, url)
115 |
116 | filename = papis_zotero.utils.download_document(
117 | url, expected_document_extension=extension)
118 | if filename is not None:
119 | files.append(filename)
120 |
121 | return files
122 |
123 |
124 | class PapisRequestHandler(http.server.BaseHTTPRequestHandler):
125 | def __init__(self, set_list: List[Tuple[str, str]], request: Any,
126 | client_address: Any, server: Any) -> None:
127 | self.set_list = set_list
128 | super().__init__(request, client_address, server)
129 |
130 | def log_message(self, fmt: str, *args: Any) -> None:
131 | logger.info(fmt, *args)
132 |
133 | def set_zotero_headers(self) -> None:
134 | self.send_header("X-Zotero-Version", ZOTERO_VERSION)
135 | self.send_header("X-Zotero-Connector-API-Version",
136 | str(ZOTERO_CONNECTOR_API_VERSION))
137 | self.end_headers()
138 |
139 | def read_input(self) -> bytes:
140 | length = int(self.headers["content-length"])
141 | return self.rfile.read(length)
142 |
143 | def do_GET(self) -> None: # noqa: N802
144 | logger.info("Received GET request at '%s'", self.path)
145 | if self.path == "/connector/ping":
146 | self.handle_get_ping()
147 |
148 | def handle_get_ping(self) -> None:
149 | self.send_response(200)
150 | self.send_header("Content-Type", "text/html")
151 | self.set_zotero_headers()
152 | response = """\
153 |
154 |
155 |
156 | Zotero Connector Server is Available
157 |
158 |
159 | Zotero Connector Server is Available
160 |
161 |
162 | """
163 |
164 | self.wfile.write(response.encode("utf-8"))
165 |
166 | def do_POST(self) -> None: # noqa: N802
167 | logger.info("Received POST request at '%s'", self.path)
168 | if self.path == "/connector/ping":
169 | self.handle_post_ping()
170 | elif self.path == "/connector/getSelectedCollection":
171 | self.handle_post_collection()
172 | elif self.path == "/connector/saveSnapshot":
173 | self.handle_post_snapshot()
174 | elif self.path == "/connector/saveItems":
175 | self.handle_post_add()
176 |
177 | def handle_post_ping(self) -> None:
178 | self.send_response(200)
179 | self.send_header("Content-Type", "application/json")
180 | self.set_zotero_headers()
181 | response = json.dumps({"prefs": {"automaticSnapshots": True}})
182 |
183 | self.wfile.write(response.encode("utf-8"))
184 |
185 | def handle_post_collection(self) -> None:
186 | self.send_response(200)
187 | self.send_header("Content-Type", "application/json")
188 | self.set_zotero_headers()
189 | papis_library = papis.api.get_lib_name()
190 |
191 | response = json.dumps({
192 | "libraryID": 1,
193 | "libraryName": papis_library,
194 | "libraryEditable": True,
195 | "editable": True,
196 | "id": None,
197 | "name": papis_library
198 | })
199 |
200 | self.wfile.write(response.encode("utf-8"))
201 |
202 | def handle_post_add(self) -> None:
203 | logger.info("Adding paper from the Zotero Connector.")
204 | rawinput = self.read_input()
205 | data = json.loads(rawinput.decode("utf-8"))
206 |
207 | logger.info("Response: %s", data)
208 | for item in data["items"]:
209 | attachments = item.get("attachments", [])
210 | if attachments:
211 | files = download_zotero_attachments(attachments)
212 | else:
213 | logger.info("Document has no attachments.")
214 | files = []
215 |
216 | papis_item = zotero_data_to_papis_data(item)
217 | if self.set_list:
218 | papis_item.update(self.set_list)
219 |
220 | logger.info("Adding paper to papis.")
221 | papis.commands.add.run(files, data=papis_item)
222 |
223 | self.send_response(201)
224 | self.set_zotero_headers()
225 |
226 | self.wfile.write(rawinput)
227 |
228 | def handle_post_snapshot(self) -> None:
229 | import tempfile
230 | import datetime
231 | import urllib.parse
232 |
233 | rawinput = self.read_input()
234 | try:
235 | data = json.loads(rawinput.decode("utf-8"))
236 | except json.JSONDecodeError as e:
237 | logger.error("Failed to decode data from the Zotero connector.", exc_info=e)
238 |
239 | html_template = """
240 |
241 |
242 | {html}
243 |
244 | """
245 | full_html = html_template.lstrip().format(**data)
246 | temp_html = tempfile.mktemp(suffix=".html")
247 | logger.debug("Writing temp html to '%s'", temp_html)
248 | with open(temp_html, mode="w") as f:
249 | f.write(full_html)
250 |
251 | current_date = datetime.datetime.now()
252 | data["date"] = data.get("date", current_date.isoformat())
253 |
254 | url = urllib.parse.urlparse(data["url"])
255 | data["author"] = url.hostname
256 |
257 | papis_item = zotero_data_to_papis_data(data)
258 |
259 | logger.info("Adding snapshot to papis.")
260 | papis.commands.add.run([temp_html], data=papis_item,
261 | folder_name=papis.config.getstring("add-folder-name")
262 | )
263 |
264 | self.send_response(201)
265 | self.set_zotero_headers()
266 |
--------------------------------------------------------------------------------
/papis_zotero/sql.py:
--------------------------------------------------------------------------------
1 | import os
2 | import re
3 | import sqlite3
4 | from datetime import datetime
5 | from typing import Any, Dict, List, Optional
6 |
7 | import papis.config
8 | import papis.bibtex
9 | import papis.strings
10 | import papis.document
11 | import papis.logging
12 | import papis.commands.add
13 |
14 | import papis_zotero.utils
15 |
16 | logger = papis.logging.get_logger(__name__)
17 |
18 | # fuzzy date matching
19 | ISO_DATE_RE = re.compile(r"(?P\d{4})-?(?P\d{2})?-?(?P\d{2})?")
20 |
21 |
22 | ZOTERO_QUERY_ITEM_FIELD = """
23 | SELECT
24 | fields.fieldName,
25 | itemDataValues.value
26 | FROM
27 | fields,
28 | itemData,
29 | itemDataValues
30 | WHERE
31 | itemData.itemID = ? AND
32 | fields.fieldID = itemData.fieldID AND
33 | itemDataValues.valueID = itemData.valueID
34 | """
35 |
36 |
37 | def get_fields(connection: sqlite3.Connection, item_id: str) -> Dict[str, str]:
38 | """
39 | :arg item_id: an identifier for the item to query.
40 | :returns: a dictionary mapping fields to their values, e.g. ``"doi"``.
41 | """
42 | cursor = connection.cursor()
43 | cursor.execute(ZOTERO_QUERY_ITEM_FIELD, (item_id,))
44 |
45 | # get fields
46 | fields = {}
47 | for name, value in cursor:
48 | if name in papis_zotero.utils.ZOTERO_EXCLUDED_FIELDS:
49 | continue
50 |
51 | name = papis_zotero.utils.ZOTERO_TO_PAPIS_FIELDS.get(name, name)
52 | fields[name] = value
53 |
54 | # get year and month from date if available
55 | date = fields.pop("date", None)
56 | if date is not None:
57 | m = ISO_DATE_RE.match(date)
58 | if m:
59 | if m.group("year"):
60 | fields["year"] = int(m.group("year"))
61 | if m.group("month"):
62 | fields["month"] = int(m.group("month"))
63 | else:
64 | # NOTE: didn't manage to match, so just save the whole date
65 | fields["date"] = date
66 |
67 | return fields
68 |
69 |
70 | ZOTERO_QUERY_ITEM_CREATORS = """
71 | SELECT
72 | creatorTypes.creatorType,
73 | creators.firstName,
74 | creators.lastName
75 | FROM
76 | creatorTypes,
77 | creators,
78 | itemCreators
79 | WHERE
80 | itemCreators.itemID = ? AND
81 | creatorTypes.creatorTypeID = itemCreators.creatorTypeID AND
82 | creators.creatorID = itemCreators.creatorID
83 | ORDER BY
84 | creatorTypes.creatorType,
85 | itemCreators.orderIndex
86 | """
87 |
88 |
89 | def get_creators(connection: sqlite3.Connection,
90 | item_id: str) -> Dict[str, List[str]]:
91 | cursor = connection.cursor()
92 | cursor.execute(ZOTERO_QUERY_ITEM_CREATORS, (item_id,))
93 |
94 | # gather creators
95 | creators_by_type: Dict[str, List[Dict[str, str]]] = {}
96 | for ctype, given_name, family_name in cursor:
97 | creators_by_type.setdefault(ctype.lower(), []).append({
98 | "given": given_name,
99 | "family": family_name,
100 | })
101 |
102 | # convert to papis format
103 | result: Dict[str, Any] = {}
104 | for ctype, creators in creators_by_type.items():
105 | result[ctype] = papis.document.author_list_to_author({"author_list": creators})
106 | result[f"{ctype}_list"] = creators
107 |
108 | return result
109 |
110 |
111 | ZOTERO_QUERY_ITEM_ATTACHMENTS = """
112 | SELECT
113 | items.key,
114 | itemAttachments.path,
115 | itemAttachments.contentType
116 | FROM
117 | itemAttachments,
118 | items
119 | WHERE
120 | itemAttachments.parentItemID = ? AND
121 | itemAttachments.contentType IN ({}) AND
122 | items.itemID = itemAttachments.itemID
123 | """.format(",".join(["?"] * len(
124 | papis_zotero.utils.ZOTERO_SUPPORTED_MIMETYPES_TO_EXTENSION)))
125 |
126 |
127 | def get_files(connection: sqlite3.Connection, item_id: str, item_key: str,
128 | input_path: str, out_folder: str) -> List[str]:
129 | cursor = connection.cursor()
130 | cursor.execute(
131 | ZOTERO_QUERY_ITEM_ATTACHMENTS,
132 | (item_id,) + tuple(papis_zotero.utils.ZOTERO_SUPPORTED_MIMETYPES_TO_EXTENSION))
133 |
134 | files = []
135 | for key, path, mime_type in cursor:
136 | if path is None:
137 | logger.warning("Attachment %s (with type %s) skipped. Path not specified.",
138 | key, mime_type)
139 | continue
140 |
141 | if match := re.match("storage:(.*)", path):
142 | file_name = match.group(1)
143 | files.append(os.path.join(input_path, "storage", key, file_name))
144 | elif os.path.exists(path):
145 | # NOTE: this is likely a symlink to some other on-disk location
146 | files.append(path)
147 | else:
148 | logger.error("Failed to export attachment %s (with type %s) from path '%s'",
149 | key, mime_type, path)
150 |
151 | return files
152 |
153 |
154 | ZOTERO_QUERY_ITEM_TAGS = """
155 | SELECT
156 | tags.name
157 | FROM
158 | tags,
159 | itemTags
160 | WHERE
161 | itemTags.itemID = ? AND
162 | tags.tagID = itemTags.tagID
163 | """
164 |
165 |
166 | def get_tags(connection: sqlite3.Connection, item_id: str) -> Dict[str, List[str]]:
167 | cursor = connection.cursor()
168 | cursor.execute(ZOTERO_QUERY_ITEM_TAGS, (item_id,))
169 |
170 | tags = [str(row[0]) for row in cursor]
171 | return {"tags": tags} if tags else {}
172 |
173 |
174 | ZOTERO_QUERY_ITEM_COLLECTIONS = """
175 | SELECT
176 | collections.collectionName
177 | FROM
178 | collections,
179 | collectionItems
180 | WHERE
181 | collectionItems.itemID = ? AND
182 | collections.collectionID = collectionItems.collectionID
183 | """
184 |
185 |
186 | def get_collections(connection: sqlite3.Connection,
187 | item_id: str) -> Dict[str, List[str]]:
188 | cursor = connection.cursor()
189 | cursor.execute(ZOTERO_QUERY_ITEM_COLLECTIONS, (item_id,))
190 |
191 | collections = [name for name, in cursor]
192 | return {"collections": collections} if collections else {}
193 |
194 |
195 | ZOTERO_QUERY_ITEM_COUNT = """
196 | SELECT
197 | COUNT(item.itemID)
198 | FROM
199 | items item,
200 | itemTypes itemType
201 | WHERE
202 | itemType.itemTypeID = item.itemTypeID AND
203 | itemType.typeName NOT IN ({})
204 | ORDER BY
205 | item.itemID
206 | """.format(",".join(["?"] * len(papis_zotero.utils.ZOTERO_EXCLUDED_ITEM_TYPES)))
207 |
208 | ZOTERO_QUERY_ITEMS = """
209 | SELECT
210 | item.itemID,
211 | itemType.typeName,
212 | key,
213 | dateAdded
214 | FROM
215 | items item,
216 | itemTypes itemType
217 | WHERE
218 | itemType.itemTypeID = item.itemTypeID AND
219 | itemType.typeName NOT IN ({})
220 | ORDER BY
221 | item.itemID
222 | """.format(",".join(["?"] * len(papis_zotero.utils.ZOTERO_EXCLUDED_ITEM_TYPES)))
223 |
224 |
225 | def add_from_sql(input_path: str,
226 | out_folder: Optional[str] = None,
227 | link: bool = False) -> None:
228 | """
229 | :param inpath: path to zotero SQLite database "zoter.sqlite" and
230 | "storage" to be imported
231 | :param outpath: path where all items will be exported to created if not
232 | existing
233 | """
234 |
235 | if out_folder is None:
236 | out_folder = papis.config.get_lib_dirs()[0]
237 |
238 | if not os.path.exists(input_path):
239 | raise FileNotFoundError(
240 | "[Errno 2] No such file or directory: '{}'".format(input_path))
241 |
242 | if not os.path.exists(out_folder):
243 | raise FileNotFoundError(
244 | "[Errno 2] No such file or directory: '{}'".format(out_folder))
245 |
246 | zotero_sqlite_file = os.path.join(input_path, "zotero.sqlite")
247 | if not os.path.exists(zotero_sqlite_file):
248 | raise FileNotFoundError(
249 | "No 'zotero.sqlite' file found in '{}'".format(input_path))
250 |
251 | connection = sqlite3.connect(zotero_sqlite_file)
252 | cursor = connection.cursor()
253 |
254 | cursor.execute(ZOTERO_QUERY_ITEM_COUNT,
255 | papis_zotero.utils.ZOTERO_EXCLUDED_ITEM_TYPES)
256 | for row in cursor:
257 | items_count = row[0]
258 |
259 | cursor.execute(ZOTERO_QUERY_ITEMS,
260 | papis_zotero.utils.ZOTERO_EXCLUDED_ITEM_TYPES)
261 | if out_folder is not None:
262 | papis.config.set_lib_from_name(out_folder)
263 |
264 | folder_name = papis.config.getstring("add-folder-name")
265 | for i, (item_id, item_type, item_key, date_added) in enumerate(cursor, start=1):
266 | # convert fields
267 | date_added = (
268 | datetime.strptime(date_added, "%Y-%m-%d %H:%M:%S")
269 | .strftime(papis.strings.time_format))
270 | item_type = papis_zotero.utils.ZOTERO_TO_PAPIS_TYPES.get(item_type, item_type)
271 |
272 | # get Zotero metadata
273 | fields = get_fields(connection, item_id)
274 | files = get_files(connection,
275 | item_id,
276 | item_key,
277 | input_path=input_path,
278 | out_folder=out_folder)
279 |
280 | item = {"type": item_type, "time-added": date_added, "files": files}
281 | item.update(fields)
282 | item.update(get_creators(connection, item_id))
283 | item.update(get_tags(connection, item_id))
284 | item.update(get_collections(connection, item_id))
285 |
286 | logger.info("[%4d/%-4d] Exporting item '%s' to library '%s'.",
287 | i, items_count, item_key, out_folder)
288 |
289 | papis.commands.add.run(paths=files, data=item, link=link,
290 | folder_name=folder_name
291 | )
292 |
293 | logger.info("Finished exporting from '%s'.", input_path)
294 | logger.info("Exported files can be found at '%s'.", out_folder)
295 |
--------------------------------------------------------------------------------
/papis_zotero/utils.py:
--------------------------------------------------------------------------------
1 | import tempfile
2 | from typing import Any, Dict, Optional
3 |
4 | import papis.utils
5 | import papis.logging
6 |
7 | logger = papis.logging.get_logger(__name__)
8 |
9 | # Zotero item types to be excluded when converting to papis
10 | ZOTERO_EXCLUDED_ITEM_TYPES = ("attachment", "note")
11 |
12 | # Zotero excluded fields
13 | ZOTERO_EXCLUDED_FIELDS = frozenset({
14 | "accessDate",
15 | "id",
16 | "shortTitle",
17 | "attachments",
18 | })
19 |
20 | # dictionary of Zotero attachments mimetypes to be included
21 | # NOTE: mapped onto their respective extension to be used in papis
22 | ZOTERO_SUPPORTED_MIMETYPES_TO_EXTENSION = {
23 | "application/vnd.ms-htmlhelp": "chm",
24 | "image/vnd.djvu": "djvu",
25 | "application/msword": "doc",
26 | "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
27 | "docx",
28 | "application/epub+zip": "epub",
29 | "application/octet-stream": "fb2",
30 | "application/x-mobipocket-ebook": "mobi",
31 | "application/pdf": "pdf",
32 | "text/rtf": "rtf",
33 | "application/zip": "zip",
34 | }
35 |
36 | # dictionary translating from zotero to papis field names
37 | ZOTERO_TO_PAPIS_FIELDS = {
38 | "abstractNote": "abstract",
39 | "publicationTitle": "journal",
40 | "DOI": "doi",
41 | "itemType": "type",
42 | "ISBN": "isbn",
43 | "ISSN": "issn",
44 | }
45 |
46 | # TODO: This mapping is copied from 'papis.bibtex.bibtex_type_converter' with
47 | # no changes. It will be available in papis>0.13, so it should be deleted and
48 | # replaced when we can depend on a newer version
49 |
50 | ZOTERO_TO_PAPIS_TYPES: Dict[str, str] = {
51 | # Zotero
52 | "annotation": "misc",
53 | "attachment": "misc",
54 | "audioRecording": "audio",
55 | "bill": "legislation",
56 | "blogPost": "online",
57 | "bookSection": "inbook",
58 | "case": "jurisdiction",
59 | "computerProgram": "software",
60 | "conferencePaper": "inproceedings",
61 | "dictionaryEntry": "misc",
62 | "document": "article",
63 | "email": "online",
64 | "encyclopediaArticle": "article",
65 | "film": "video",
66 | "forumPost": "online",
67 | "hearing": "jurisdiction",
68 | "instantMessage": "online",
69 | "interview": "article",
70 | "journalArticle": "article",
71 | "magazineArticle": "article",
72 | "manuscript": "unpublished",
73 | "map": "misc",
74 | "newspaperArticle": "article",
75 | "note": "misc",
76 | "podcast": "audio",
77 | "preprint": "unpublished",
78 | "presentation": "misc",
79 | "radioBroadcast": "audio",
80 | "statute": "jurisdiction",
81 | "tvBroadcast": "video",
82 | "videoRecording": "video",
83 | "webpage": "online",
84 | # Others
85 | "journal": "article",
86 | "monograph": "book",
87 | }
88 |
89 |
90 | # TODO: this function is copied from `papis.downloaders.__init__` with no
91 | # changes. It will be available in papis>0.13, so it should be deleted when
92 | # we can depend on a newer version
93 |
94 | def download_document(
95 | url: str,
96 | expected_document_extension: Optional[str] = None,
97 | cookies: Optional[Dict[str, Any]] = None,
98 | ) -> Optional[str]:
99 | """Download a document from *url* and store it in a local file.
100 |
101 | :param url: the URL of a remote file.
102 | :param expected_document_extension: an expected file type. If *None*, then
103 | an extension is guessed from the file contents, but this can also fail.
104 | :returns: a path to a local file containing the data from *url*.
105 | """
106 | if cookies is None:
107 | cookies = {}
108 |
109 | try:
110 | with papis.utils.get_session() as session:
111 | response = session.get(url, cookies=cookies, allow_redirects=True)
112 | except Exception as exc:
113 | logger.error("Failed to fetch '%s'.", url, exc_info=exc)
114 | return None
115 |
116 | if not response.ok:
117 | logger.error("Could not download document '%s'. (HTTP status: %s %d).",
118 | url, response.reason, response.status_code)
119 | return None
120 |
121 | ext = expected_document_extension
122 | if ext is None:
123 | from papis.filetype import guess_content_extension
124 | ext = guess_content_extension(response.content)
125 | if not ext:
126 | logger.warning("Downloaded document does not have a "
127 | "recognizable (binary) mimetype: '%s'.",
128 | response.headers["Content-Type"])
129 |
130 | ext = ".{}".format(ext) if ext else ""
131 | with tempfile.NamedTemporaryFile(
132 | mode="wb+",
133 | suffix=ext,
134 | delete=False) as f:
135 | f.write(response.content)
136 |
137 | return f.name
138 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [build-system]
2 | build-backend = "hatchling.build"
3 | requires = [ "hatchling>=1.10" ]
4 |
5 | [project]
6 | name = "papis-zotero"
7 | version = "0.2"
8 | description = "Interact with Zotero using papis"
9 | readme = "README.rst"
10 | keywords = [ "bibtex", "biliography", "cli", "management", "papis", "zotero" ]
11 | license = { text = "GPL-3.0-or-later" }
12 | maintainers = [ { name = "Alejandro Gallo", email = "aamsgallo@gmail.com" } ]
13 | authors = [ { name = "Alejandro Gallo", email = "aamsgallo@gmail.com" } ]
14 | requires-python = ">=3.8"
15 | classifiers = [
16 | "Environment :: Console",
17 | "Environment :: Console :: Curses",
18 | "Intended Audience :: Developers",
19 | "Intended Audience :: Education",
20 | "Intended Audience :: Science/Research",
21 | "Intended Audience :: System Administrators",
22 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
23 | "Operating System :: MacOS",
24 | "Operating System :: Microsoft",
25 | "Operating System :: OS Independent",
26 | "Operating System :: POSIX",
27 | "Operating System :: Unix",
28 | "Programming Language :: Python :: 3 :: Only",
29 | "Programming Language :: Python :: 3.8",
30 | "Programming Language :: Python :: 3.9",
31 | "Programming Language :: Python :: 3.10",
32 | "Programming Language :: Python :: 3.11",
33 | "Programming Language :: Python :: 3.12",
34 | "Programming Language :: Python :: 3.13",
35 | "Topic :: Utilities",
36 | ]
37 | dependencies = [ "papis>=0.14,<0.15" ]
38 |
39 | [project.optional-dependencies]
40 | develop = [
41 | "flake8",
42 | "flake8-bugbear",
43 | "flake8-pyproject",
44 | "flake8-quotes",
45 | "mypy>=0.7",
46 | "pep8-naming",
47 | "pytest",
48 | "pytest-cov",
49 | "python-coveralls",
50 | "types-pyyaml",
51 | ]
52 |
53 | [project.urls]
54 | Repository = "https://github.com/papis/papis-zotero"
55 |
56 | [project.entry-points."papis.command"]
57 | zotero = "papis_zotero:main"
58 |
59 | [tool.flake8]
60 | select = [ "B", "D", "E", "F", "N", "Q", "W" ]
61 | extend-ignore = [ "B019", "E123", "N818", "W503" ]
62 | max-line-length = 88
63 | inline-quotes = "double"
64 | multiline-quotes = "double"
65 |
66 | [tool.pytest.ini_options]
67 | addopts = [
68 | "--doctest-modules",
69 | "--cov=papis_zotero",
70 | ]
71 | norecursedirs = ".git doc build dist"
72 | python_files = "*.py"
73 | markers = [
74 | "config_setup: setup for tmp_config",
75 | "library_setup: setup for tmp_library",
76 | ]
77 |
78 | [tool.mypy]
79 | strict = true
80 | show_column_numbers = true
81 | hide_error_codes = false
82 | pretty = true
83 | warn_unused_ignores = true
84 |
--------------------------------------------------------------------------------
/tests/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/.gitkeep
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/__init__.py
--------------------------------------------------------------------------------
/tests/resources/bibtex/files/10/De Lellis and Székelyhidi - 2009 - The Euler equations as a differential inclusion.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/bibtex/files/10/De Lellis and Székelyhidi - 2009 - The Euler equations as a differential inclusion.pdf
--------------------------------------------------------------------------------
/tests/resources/bibtex/files/12/Grubb - 2015 - Fractional Laplacians on domains, a development of.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/bibtex/files/12/Grubb - 2015 - Fractional Laplacians on domains, a development of.pdf
--------------------------------------------------------------------------------
/tests/resources/bibtex/files/15/Svärd and Nordström - 2014 - Review of summation-by-parts schemes for initial–b.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/bibtex/files/15/Svärd and Nordström - 2014 - Review of summation-by-parts schemes for initial–b.pdf
--------------------------------------------------------------------------------
/tests/resources/bibtex/files/8/Schaeffer - 2013 - Efficient spherical harmonic transforms aimed at p.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/bibtex/files/8/Schaeffer - 2013 - Efficient spherical harmonic transforms aimed at p.pdf
--------------------------------------------------------------------------------
/tests/resources/bibtex/zotero-library.bib:
--------------------------------------------------------------------------------
1 |
2 | @article{schaeffer_efficient_2013,
3 | title = {Efficient spherical harmonic transforms aimed at pseudospectral numerical simulations},
4 | volume = {14},
5 | issn = {15252027},
6 | url = {http://doi.wiley.com/10.1002/ggge.20071},
7 | doi = {10.1002/ggge.20071},
8 | shorttitle = {Efficient spherical harmonic transforms aimed at pseudospectral numerical simulations},
9 | pages = {751--758},
10 | number = {3},
11 | journaltitle = {Geochem. Geophys. Geosyst.},
12 | author = {Schaeffer, Nathanaël},
13 | urldate = {2023-02-26},
14 | date = {2013-03},
15 | langid = {english}
16 | file = {Full Text:files/8/Schaeffer - 2013 - Efficient spherical harmonic transforms aimed at p.pdf:application/pdf},
17 | }
18 |
19 | @article{de_lellis_euler_2009,
20 | title = {The Euler equations as a differential inclusion},
21 | volume = {170},
22 | issn = {0003-486X},
23 | url = {http://annals.math.princeton.edu/2009/170-3/p09},
24 | doi = {10.4007/annals.2009.170.1417},
25 | pages = {1417--1436},
26 | number = {3},
27 | journaltitle = {Ann. Math.},
28 | author = {De Lellis, Camillo and Székelyhidi, László},
29 | urldate = {2023-02-26},
30 | date = {2009-11-01},
31 | langid = {english},
32 | file = {Submitted Version:files/10/De Lellis and Székelyhidi - 2009 - The Euler equations as a differential inclusion.pdf:application/pdf},
33 | }
34 |
35 | @article{grubb_fractional_2015,
36 | title = {Fractional Laplacians on domains, a development of Hörmander's theory of μ-transmission pseudodifferential operators},
37 | volume = {268},
38 | issn = {00018708},
39 | url = {https://linkinghub.elsevier.com/retrieve/pii/S0001870814003302},
40 | doi = {10.1016/j.aim.2014.09.018},
41 | pages = {478--528},
42 | journaltitle = {Advances in Mathematics},
43 | author = {Grubb, Gerd},
44 | urldate = {2023-02-26},
45 | date = {2015-01},
46 | langid = {english},
47 | file = {Full Text:files/12/Grubb - 2015 - Fractional Laplacians on domains, a development of.pdf:application/pdf},
48 | }
49 |
50 | @article{morinishi_fully_1998,
51 | title = {Fully Conservative Higher Order Finite Difference Schemes for Incompressible Flow},
52 | volume = {143},
53 | issn = {00219991},
54 | url = {https://linkinghub.elsevier.com/retrieve/pii/S0021999198959629},
55 | doi = {10.1006/jcph.1998.5962},
56 | pages = {90--124},
57 | number = {1},
58 | journaltitle = {Journal of Computational Physics},
59 | author = {Morinishi, Y. and Lund, T.S. and Vasilyev, O.V. and Moin, P.},
60 | urldate = {2023-02-26},
61 | date = {1998-06},
62 | langid = {english},
63 | }
64 |
65 | @article{svard_review_2014,
66 | title = {Review of summation-by-parts schemes for initial–boundary-value problems},
67 | volume = {268},
68 | issn = {00219991},
69 | url = {https://linkinghub.elsevier.com/retrieve/pii/S002199911400151X},
70 | doi = {10.1016/j.jcp.2014.02.031},
71 | pages = {17--38},
72 | journaltitle = {Journal of Computational Physics},
73 | author = {Svärd, Magnus and Nordström, Jan},
74 | urldate = {2023-02-26},
75 | date = {2014-07},
76 | langid = {english},
77 | keywords = {sbp},
78 | file = {Submitted Version:files/15/Svärd and Nordström - 2014 - Review of summation-by-parts schemes for initial–b.pdf:application/pdf},
79 | }
80 |
--------------------------------------------------------------------------------
/tests/resources/bibtex_out.yaml:
--------------------------------------------------------------------------------
1 | author: Svärd, Magnus and Nordström, Jan
2 | author_list:
3 | - family: Svärd
4 | given: Magnus
5 | - family: Nordström
6 | given: Jan
7 | doi: 10.1016/j.jcp.2014.02.031
8 | files:
9 | - svard-and-nordstrom-2014-review-of-summation-by-parts-schemes-for-initial-b.pdf
10 | issn: 00219991
11 | journaltitle: Journal of Computational Physics
12 | langid: english
13 | month: 7
14 | pages: 17--38
15 | ref: svard_review_2014
16 | tags:
17 | - sbp
18 | title: Review of summation-by-parts schemes for initial–boundary-value problems
19 | type: article
20 | url: https://linkinghub.elsevier.com/retrieve/pii/S002199911400151X
21 | urldate: '2023-02-26'
22 | volume: '268'
23 | year: 2014
24 |
--------------------------------------------------------------------------------
/tests/resources/sql/storage/5KW7TMDH/.zotero-ft-cache:
--------------------------------------------------------------------------------
1 | 15252027, 2013, 3, Downloaded from https://agupubs.onlinelibrary.wiley.com/doi/10.1002/ggge.20071 by Cochrane Romania, Wiley Online Library on [26/02/2023]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License
2 |
3 | Article Volume 14, Number 3
4 | 6 March 2013 doi:10.1002/ggge.20071
5 | ISSN: 1525-2027
6 |
7 | Efficient spherical harmonic transforms aimed at pseudospectral numerical simulations
8 | Nathanaël Schaeffer
9 | ISTerre, Université de Grenoble 1, CNRS, F-38041 Grenoble, France (nathanael.schaeffer@ujf-grenoble.fr)
10 | [1] In this paper, we report on very efficient algorithms for spherical harmonic transform (SHT). Explicitly vectorized variations of the algorithm based on the Gauss-Legendre quadrature are discussed and implemented in the SHTns library, which includes scalar and vector transforms. The main breakthrough is to achieve very efficient on-the-fly computations of the Legendre-associated functions, even for very high resolutions, by taking advantage of the specific properties of the SHT and the advanced capabilities of current and future computers. This allows us to simultaneously and significantly reduce memory usage and computation time of the SHT. We measure the performance and accuracy of our algorithms. Although the complexity of the algorithms implemented in SHTns are in OðN 3Þ (where N is the maximum harmonic degree of the transform), they perform much better than any third-party implementation, including lower-complexity algorithms, even for truncations as high as N = 1023. SHTns is available at https://bitbucket.org/nschaeff/shtns as open source software.
11 | Components: 3,700 words, 5 figures.
12 | Keywords: spherical harmonics; performance; mathematical software.
13 | Index Terms: 1932 Informatics: High-performance computing; 1976 Informatics: Software tools and services; 3255 Mathematical Geophysics (0500, 4307, 4314, 4400, 7833): Spectral analysis (3205, 3280, 4319); 1906 Informatics: Computational models, algorithms; 1510 Geomagnetism And Paleomagnetism: Dynamo: theories and simulations.
14 | Received 11 December 2012; Revised 15 January 2013; Accepted 15 January 2013; Published 6 March 2013.
15 | Schaeffer, N. (2013), Efficient spherical harmonic transforms aimed at pseudospectral numerical simulations, Geochem. Geophys. Geosyst., 14, 751–758, doi:10.1002/ggge.20071.
16 |
17 | 1. Introduction
18 | [2] Spherical harmonics are the eigenfunctions of the Laplace operator on the 2-sphere. They form a basis and are useful and convenient to describe data on a sphere in a consistent way in spectral space. Spherical harmonic transforms (SHT) are the spherical counterpart of the Fourier transform, casting spatial data to the spectral domain and vice versa. They are commonly used in various pseudospectral direct numerical simulations in spherical geometry,
19 |
20 | for simulating the Sun or the liquid core of the Earth among others [Glatzmaier, 1984; Sakuraba, 1999; Christensen et al., 2001; Brun & Rempel, 2009; Wicht & Tilgner, 2010].
21 | [3] All numerical simulations that take advantage of spherical harmonics use the classical Gauss-Legendre algorithm (see section 2) with complexity OðN 3Þ for a truncation at spherical harmonic degree N. As a consequence of this high computational cost when N increases, high-resolution spherical codes currently spend most of their time performing SHT. A few years
22 |
23 | ©2013. American Geophysical Union. All Rights Reserved.
24 |
25 | 751
26 |
27 | 15252027, 2013, 3, Downloaded from https://agupubs.onlinelibrary.wiley.com/doi/10.1002/ggge.20071 by Cochrane Romania, Wiley Online Library on [26/02/2023]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License
28 |
29 | Geochemistry
30 | 3 Geophysics
31 | G Geosystems
32 |
33 | SCHAEFFER: EFFICIENT SPHERICAL HARMONIC TRANSFORM
34 |
35 | 10.1002/ggge.20071
36 |
37 | ago, state-of-the-art numerical simulations used N = 255 [Sakuraba & Roberts, 2009].
38 | [4] However, there exist several asymptotically fast algorithms [Driscoll & Healy, 1994; Potts et al., 1998; Mohlenkamp, 1999; Suda & Takami, 2002; Healy et al., 2003; Tygert, 2008], but the overhead for these fast algorithms is such that they do not claim to be effectively faster for N < 512. In addition, some of them lack stability (the error becomes too large even for moderate N) and flexibility (e.g., N + 1 must be a power of 2).
39 | [5] Among the asymptotically fast algorithms, only two have open-source implementations, and the only one that seems to perform reasonably well is SpharmonicKit, based on the algorithms described by Healy et al. [Healy et al., 2003]. Its main drawback is the need of a latitudinal grid of size 2(N + 1), while the Gauss-Legendre quadrature allows the use of only N + 1 collocation points. Thus, even if it were as fast as the GaussLegendre approach for the same truncation N, the overall numerical simulation would be slower because it would operate on twice as many points. These facts explain why the Gauss-Legendre algorithm is still the most efficient solution for numerical simulations.
40 | [6] A recent paper [Dickson et al., 2011] reports that a carefully tuned software could finally run nine times faster on the same CPU than the initial nonoptimized version, and insists on the importance of vectorization and careful optimization of the code. As the goal of this work is to speed up numerical simulations, we have written a highly optimized and explicitly vectorized version of the Gauss-Legendre SHT algorithm. The next section recalls the basics of spherical harmonic transforms. We then describe the optimizations we used and compare the performance of our transform to other SHT implementations. We conclude this paper by a short summary and perspectives for future developments.
41 |
42 | 2. Spherical Harmonic Transform
43 | 2.1. Definitions and Properties [7] The orthonormalized spherical harmonics of degree n and order À n ≤ m ≤ n are functions defined on the sphere as:
44 |
45 | Ynmðθ; ’Þ ¼ PnmðcosθÞexpðim’Þ
46 |
47 | (1)
48 |
49 | where θ is the colatitude, ’ is the longitude, and Pnm are the associated Legendre polynomials normal-
50 |
51 | ized for spherical harmonics
52 |
53 | rffiffiffiffiffiffiffiffiffiffiffiffiffisffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
54 |
55 | PnmðxÞ ¼ ðÀ1Þm
56 |
57 | 2n þ 1 4p
58 |
59 | ðn ðn
60 |
61 | À þ
62 |
63 | jmjÞ!À jmjÞ! 1
64 |
65 | À
66 |
67 | x2Ájmj=2
68 |
69 | djmj dxjmj
70 |
71 | Pn
72 |
73 | ðxÞ
74 |
75 | (2)
76 |
77 | which involve derivatives of Legendre polynomials Pn(x) defined by the following recurrence:
78 | P0ðxÞ ¼ 1 P1ðxÞ ¼ x nPnðxÞ ¼ ð2n À 1ÞxPnÀ1ðxÞ À ðn À 1ÞPnÀ2ðxÞ
79 | The spherical harmonics Ynmðθ; ’Þ form an orthonormal basis for functions defined on the sphere:
80 |
81 | Z 2p Z p
82 |
83 | Ynmðθ; ’ÞYlkðθ; ’Þsinθdθd’ ¼ dnldmk
84 |
85 | (3)
86 |
87 | 00
88 |
89 | with dij the Kronecker symbol. By construction, they are eigenfunctions of the Laplace operator on
90 | the unit sphere:
91 |
92 | ΔYnm ¼ Ànðn þ 1ÞYnm
93 |
94 | (4)
95 |
96 | This property is very appealing for solving many physical problems in spherical geometry involving the Laplace operator.
97 |
98 | 2.2. Synthesis or Inverse Transform
99 | [8] The spherical harmonic synthesis is the evaluation of the sum
100 |
101 | XN Xn
102 |
103 | f ðθ; ’Þ ¼
104 |
105 | fnmYnmðθ; ’Þ
106 |
107 | (5)
108 |
109 | n¼0 m¼Àn
110 |
111 | up to degree n = N, given the complex coefficients
112 |
113 | Àfnfmnm. ÁIÃf,
114 |
115 | f(θ,’) is a where z*
116 |
117 | real-valued function, then fnÀm ¼ stands for the complex conjugate
118 |
119 | of z.
120 |
121 | [9] The sums can be exchanged; and using the ex-
122 |
123 | pression of Ynm we can write
124 |
125 | 0
126 |
127 | 1
128 |
129 | XN XN
130 |
131 | f ðθ; ’Þ ¼
132 |
133 | @ fnmPnmðcosθÞAeim’
134 |
135 | (6)
136 |
137 | m¼ÀN n¼jmj
138 |
139 | From this last expression, it appears that the summation over m is a regular Fourier transform. Hence, the remaining task is to evaluate
140 |
141 | XN
142 |
143 | fmðθÞ ¼
144 |
145 | fnmPnmðcosθÞ
146 |
147 | (7)
148 |
149 | n¼jmj
150 |
151 | or its discrete version at given collocation points θj.
152 |
153 | 752
154 |
155 | 15252027, 2013, 3, Downloaded from https://agupubs.onlinelibrary.wiley.com/doi/10.1002/ggge.20071 by Cochrane Romania, Wiley Online Library on [26/02/2023]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License
156 |
157 | Geochemistry
158 | 3 Geophysics
159 | G Geosystems
160 |
161 | SCHAEFFER: EFFICIENT SPHERICAL HARMONIC TRANSFORM
162 |
163 | 10.1002/ggge.20071
164 |
165 | 2.3. Analysis or Forward Transform
166 |
167 | [10] The analysis step of the SHT consists in computing the coefficients
168 |
169 | Z 2p Z p
170 |
171 | fnm ¼
172 |
173 | f ðθ; ’ÞYnmðθ; ’Þsinθdθd’
174 |
175 | (8)
176 |
177 | 00
178 |
179 | The integral over ’ is obtained using the Fourier
180 |
181 | transform:
182 |
183 | Z 2p
184 |
185 | fmðθÞ ¼ f ðθ; ’Þeim’d’
186 |
187 | (9)
188 |
189 | 0
190 |
191 | so the remaining Legendre transform reads
192 |
193 | Zp
194 |
195 | fnm ¼ fmðθÞPnmðcosθÞsinθdθ
196 |
197 | (10)
198 |
199 | 0
200 |
201 | The discrete problem reduces to the appropriate
202 | quadrature rule to evaluate the integral (10) knowing only the values fm(θj). In particular, the use of the Gauss-Legendre quadrature replaces the inte-
203 | gral of expression (10) by the sum
204 |
205 | X Nθ À Á À Á
206 |
207 | fnm ¼ fm θj Pnm cosθj wj
208 |
209 | (11)
210 |
211 | j¼1
212 |
213 | where θj and wj are, respectively, the Gauss nodes and weights [Temme, 2011]. Note that the sum equals the integral if fmðθÞPnmðcosθÞ is a polynomial in cosθ of order 2Nθ À 1 or less. If fm(θ) is given by expression (7), then fmðθÞPnmðcosθÞ is always a polynomial in cosθ, of degree at most 2N. Hence, the GaussLegendre quadrature is exact for Nθ ≥ N + 1.
214 | [11] A discrete spherical harmonic transform using Gauss nodes as latitudinal grid points and a Gauss-Legendre quadrature for the analysis step is referred to as a Gauss-Legendre algorithm.
215 |
216 | 3. Optimization of the Gauss-Legendre Algorithm
217 | 3.1. Standard Optimizations [12] Let us first recall some standard optimizations found in almost every serious implementation of the Gauss-Legendre algorithm. All the following optimizations are used in the SHTns library.
218 | 3.1.1. Use the Fast-Fourier Transform
219 | [13] The expressions in section 2 show that part of the SHT is in fact a Fourier transform. The fast Fourier transform (FFT) should be used for this part, as it improves accuracy and speed. SHTns uses the FFTW
220 |
221 | library [Frigo & Johnson, 2005], a portable, flexible, and highly efficient FFT implementation.
222 |
223 | 3.1.2. Take Advantage of Hermitian Symmetry for Real Data
224 |
225 | [14] tral
226 |
227 | When dealing with coefficients fulfill
228 |
229 | frnÀeaml-¼vaÀlufnemdÁÃd,atsao,
230 |
231 | the we
232 |
233 | speconly
234 |
235 | need to store them for m ≥ 0. This also allows the
236 |
237 | use of faster real-valued FFTs.
238 |
239 | 3.1.3. Take Advantage of Mirror Symmetry
240 | [15] Due to the defined symmetry of spherical harmonics with respect to a reflection about the equator
241 | Pnmðcosðp À θÞÞ ¼ ðÀ1ÞnþmPnmðcosθÞ
242 | one can reduce by a factor of 2 the operation count of both forward and inverse transforms.
243 |
244 | 3.1.4. Precompute Values of Pnm ÀÁ
245 | [16] The coefficients Pnm cosθj appear in both synthesis and analysis expressions (7 and 10), and can be precomputed and stored for all (n,m,j). When performing multiple transforms, it avoids computing the Legendre polynomial recursion at every transform and saves some computing power, at the expense of memory bandwidth. This may or may not be efficient, as we will discuss later.
246 |
247 | 3.1.5. Polar Optimization
248 |
249 | [17] High-order spherical harmonics have their magnitude decrease exponentially when approaching the poles as shown in Figure 1. Hence, the integral of expression (10) can be reduced to
250 |
251 | Z pÀθm0 n
252 |
253 | fnm ¼
254 |
255 | fmðθÞPnmðcosθÞsinθdθ
256 |
257 | (12)
258 |
259 | θm0 n
260 |
261 | where θm0 n≥0 is a threshold below which Pnm is consid-
262 |
263 | ered to be zero. Similarly, the synthesis of fm(θ) (equa-
264 |
265 | tion uses
266 |
267 | (7)) is only a threshold
268 |
269 | needed θm0 n that
270 |
271 | for θm0 n≤θ≤p À θm0 n does not depend on
272 |
273 | . SHTns n, which
274 |
275 | leads to around 5% to 20% speed increase, depending
276 |
277 | on the desired accuracy and the truncation N.
278 |
279 | 3.2. On-the-Fly Algorithms and Vectorization [18] It can be shown that PnmðxÞ can be computed recursively by
280 | 753
281 |
282 | 15252027, 2013, 3, Downloaded from https://agupubs.onlinelibrary.wiley.com/doi/10.1002/ggge.20071 by Cochrane Romania, Wiley Online Library on [26/02/2023]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License
283 |
284 | Geochemistry
285 | 3 Geophysics
286 | G Geosystems
287 |
288 | SCHAEFFER: EFFICIENT SPHERICAL HARMONIC TRANSFORM
289 |
290 | 10.1002/ggge.20071
291 |
292 | 1.5
293 |
294 | 1
295 |
296 | 0.5
297 |
298 | 0
299 |
300 | -0.5
301 |
302 | -1
303 |
304 | -1.5
305 |
306 | 0
307 |
308 | 0.5
309 |
310 | 1
311 |
312 | 1.5
313 |
314 | 2
315 |
316 | 2.5
317 |
318 | 3
319 |
320 | θ
321 |
322 | Figure 1. Two associated Legendre polynomials of degree n = 40 and order m = 33 (blue) and m = 36 (red), showing the localization near the equator.
323 |
324 | PmmðxÞ
325 |
326 | ¼
327 |
328 | amm
329 |
330 | À 1
331 |
332 | À
333 |
334 | x2Ájmj=2
335 |
336 | (13)
337 |
338 | Pmmþ1ðxÞ ¼ ammþ1xPmmðxÞ
339 |
340 | (14)
341 |
342 | PnmðxÞ ¼ amn xPnmÀ1ðxÞ þ bmn PnmÀ2ðxÞ
343 |
344 | (15)
345 |
346 | with
347 |
348 | amm
349 |
350 | ¼
351 |
352 | v u u tffiffi1ffiffiffiffiffiffiY ffijffimffiffijffiffiffi2ffiffiffikffiffiffiþffiffiffiffiffi1ffiffi 4p k¼1 2k
353 |
354 | (16)
355 |
356 | rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
357 |
358 | amn ¼
359 |
360 | 4n2 À 1 n2 À m2
361 |
362 | (17)
363 |
364 | sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
365 |
366 | bmn ¼ À
367 |
368 | 2n þ 1 ðn À 1Þ2 À m2 2n À 3 n2 À m2
369 |
370 | (18)
371 |
372 | The coefficients amn and bmn do not depend on x, and
373 |
374 | can be easily precomputed and stored into an array
375 |
376 | of (N order
377 |
378 | + 1)2 values. N3 values of
379 |
380 | ThisÀ hÁas Pnm xj ,
381 |
382 | to be which
383 |
384 | compared to the are usually pre-
385 |
386 | computed and stored in the spherical harmonic
387 |
388 | transforms implemented in numerical simulations.
389 |
390 | TheÀ aÁmount of memory required to Pnm xj in double-precision is at least
391 |
392 | store all 2(N + 1)3
393 |
394 | bytes, which gives 2 Gb for N = 1023. Our on-the-
395 |
396 | fly algorithm only needs about 8(N + 1)2 bytes of
397 |
398 | storage (same size as a spectral representation fnm),
399 |
400 | that is, 8 Mb for N = 1023. When N becomeÀs Ávery large, it is no longer possible to store Pnm xj in
401 |
402 | memory (for N ≳1024 nowadays) and on-the-fly ÀÁ
403 | algorithms (which recompute Pnm xj from the recurrence relation when needed) are then the only
404 |
405 | possibility.
406 |
407 | [19] We would like to stress that even far from that storage limit, on-the-fly algorithm can be significantly faster thanks to vector capabilities of modern
408 |
409 | processors. Most desktop and laptop computers, as well as many high-performance computing clusters, have support for single-instruction, multiple-data (SIMD) operations in double precision. The SSE2 instruction set is available since year 2000 and currently supported by almost every PC, allowing the performance of the same double-precision arithmetic operations on a vector of two doubleprecision numbers, effectively doubling the computing power. The recently introduced AVX instruction set increases the vector size to four double-precision numbers. This means that PnmðxÞ can be computed from the recursion relation (15) (which requires three multiplications and one addition) for two or four values of x simultaneously, which may be faster than loading precomputed values from memory. Hence, as already pointed out by Dickson et al. [Dickson et al., 2011], it is therefore very important to use the vector capabilities of modern processors to address their full computing power. Furthermore, when running multiple transforms on the different cores of a computer, the performance of on-the-fly transforms (which use less memory bandwidth) scales much better than algorithms with precomputed matrices, because the memory bandwidth is shared between cores. Superscalar architectures that do not have double-precision SIMD instructions but have many computation units per core (like the POWER7 or SPARC64) could also benefit from on-the-fly transforms by saturating the many computation units with independent computations (at different x).
410 | [20] Figure 2 shows the benefit of explicit vectorization of on-the-fly algorithms on an Intel Xeon E5-2680 (Sandy Bridge architecture with AVX instruction set running at 2.7 GHz) and compares on-the-fly algorithms with algorithms based on precomputed matrices. With the four vectors of AVX, the fastest algorithm is always on the fly, while for two vectors, the fastest algorithm uses precomputed matrices for N ≲200 . In the forthcoming years, wider vector architecture is expected to become widely available, and the benefits of on-the-fly vectorized transforms will become even more important.
411 | 3.2.1. Runtime Tuning
412 | [21] We have now two different available algorithms: one uses precomputed values for PnmðxÞ and the other one computes them on the fly at each transform. The SHTns library compares the time taken by those algorithms (and variants) at startup and chooses the fastest, similarly to what the FFTW
413 | 754
414 |
415 | 15252027, 2013, 3, Downloaded from https://agupubs.onlinelibrary.wiley.com/doi/10.1002/ggge.20071 by Cochrane Romania, Wiley Online Library on [26/02/2023]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License
416 |
417 | Geochemistry
418 | 3 Geophysics
419 | G Geosystems
420 |
421 | SCHAEFFER: EFFICIENT SPHERICAL HARMONIC TRANSFORM
422 |
423 | 10.1002/ggge.20071
424 |
425 | Figure 2. Efficiency (N + 1)3/(2tf ) of various algorithms, where t is the execution time and f the frequency of the Xeon E5-2680 CPU (2.7 GHz). On-the-fly algorithms with two different vector sizes are compared with the algorithm using precomputed matrices. Note the influence of hardware vector size for on-the-fly algorithms (AVX vectors pack four double-precision floating point numbers where SSE3 vectors pack only two). The efficiency of the algorithm based on precomputed matrices drops above N = 127 probably due to cache size limitations.
426 | library [Frigo & Johnson, 2005] does. The time overhead required by runtime tuning can be several orders of magnitude larger than that of a single transform. The observed performance gain varies between 10% and 30%. This is significant for numerical simulations, but runtime tuning can be entirely skipped for applications performing only a few transforms, in which case there is no noticeable overhead.
427 | 3.3. Multithreaded Transform
428 | [22] Modern computers have several computing cores. We use OpenMP to implement a multithreaded algorithm for the Legendre transform including the above optimizations and the on-the-fly approach. The lower memory bandwidth requirements for the on-the-fly approach is an asset for a multithreaded transform because if each thread would read a different portion of a large matrix, it can saturate the memory bus very quickly. The multithreaded Fourier transform is left to the FFTW library.
429 | [23] We need to decide how to share the work between different threads. Because we compute the Pnm on the fly using the recurrence relation (15), we are left with each thread computing different θ, or different m. As the analysis step involves a sum over θ, we choose the latter option.
430 | [24] From equation (7), we see that the number of terms involved in the sum depends on m, so that the computing cost will also depend on m. To
431 |
432 | achieve the best workload balance between a team of p threads, the thread number i (0 ≤ i < p) handles m = i + kp ≤ N, with integer k from 0 to (N + 1)p. [25] For different thread number b, we have measured the time Ts(p) and Ta(p) needed for a scalar spherical harmonic synthesis and analysis, respectively (including the FFT). [26] Figure 3 shows the speedup T(1)/T(p), where T(p) is the largest of Ts(p) and Ta(p), and T(1) is the time of the fastest single threaded transform. It shows that there is no point in doing a parallel transform with N below 128. The speedup is good for N ¼ 255 or above, and excellent up to eight threads for N ≥ 511 or up to 16 threads for very large transform (N ≥ 2047).
433 | 3.4. Performance Comparisons [27] Table 1 reports the timing measurements of two SHT libraries, compared to the optimized GaussLegendre implementation found in the SHTnslibrary (this work). We compare with the Gauss-Legendre implementation of libpsht [Reinecke, 2011] a parallel spherical harmonic transform library targeting very large N, and with SpharmonicKit 2.7 (DH) which implements one of the Driscoll-Healy fast algorithms [Healy et al., 2003]. All the timings are for a complete SHT, which includes the fast Fourier transform. Note that the Gauss-Legendre algorithm is by far (a factor of order 2) the fastest algorithm of the libpsht library. Note also that SpharmonicKit is limited to N + 1 being a power of two, requires 2 (N + 1) latitudinal colocation points, and crashed for N = 2047. The software library implementing the fast
434 | Figure 3. Speedup obtained with multiple threads using OpenMP (gcc 4.6.3) on a 16-core Intel Xeon E5-2680 (Sandy Bridge architecture with AVX instruction set running at 2.7 GHz).
435 | 755
436 |
437 | 15252027, 2013, 3, Downloaded from https://agupubs.onlinelibrary.wiley.com/doi/10.1002/ggge.20071 by Cochrane Romania, Wiley Online Library on [26/02/2023]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License
438 |
439 | Geochemistry
440 | 3 Geophysics
441 | G Geosystems
442 |
443 | SCHAEFFER: EFFICIENT SPHERICAL HARMONIC TRANSFORM
444 |
445 | 10.1002/ggge.20071
446 |
447 | Table 1. Comparison of Execution Time for Different SHT Implementations
448 |
449 | N
450 |
451 | 63
452 |
453 | 127
454 |
455 | 255
456 |
457 | 511
458 |
459 | 1023
460 |
461 | 2047
462 |
463 | 4095
464 |
465 | libpsht (1 thread) DH (fast) SHTns (1 thread)
466 |
467 | 1.05 ms 1.1 ms 0.09 ms
468 |
469 | 4.7 ms 5.5 ms 0.60 ms
470 |
471 | 27 ms 21 ms
472 | 4.2 ms
473 |
474 | 162 ms 110 ms
475 | 28 ms
476 |
477 | 850 ms 600 ms 216 ms
478 |
479 | 4.4 s NA
480 | 1.6 s
481 |
482 | 30.5 s NA 11.8 s
483 |
484 | The numbers correspond to the average execution time for forward and backward scalar transform (including the FFT) on an Intel Xeon X5650 (2.67GHz) with 12 cores. The programs were compiled with gcc 4.4.5 and -O3 -march=native -ffast-math compilation options.
485 |
486 | Legendre transform described by Mohlenkamp [Mohlenkamp, 1999], libftsh, has also been tested and found to be of comparable performance to that of SpharmonicKit, although the comparison is not straightforward because libftsh did not include the Fourier transform. Again, that fast library could not operate at N = 2047 because of memory limitations. Note finally that these measurements were performed on a machine that did not support the new AVX instruction set. [28] To ease the comparison, we define the efficiency of the SHT by (N + 1)3/(2Tf ), where T is the execution time (reported in Table 1) and f the frequency of the CPU. Note that (N + 1)3/2 reflects the number of computation elements of a Gauss-Legendre algorithm [the number of modes (N + 1)(N + 2)/2 times the number of latitudinal points N + 1]. An efficiency that does not depend on N corresponds to an algorithm with an execution time proportional to N3. [29] The efficiency of the tested algorithms is displayed in Figure 4. Not surprisingly, the Driscoll-Healy implementation has the largest slope, which means that its efficiency grows fastest with N, as expected for a fast algorithm. It also performs slightly better than libpsht for N ≥ 511. However, even for N = 1023 (the largest size that it can compute), it is still 2.8 times slower than the Gauss-Legendre algorithm implemented in
487 | Figure 4. Efficiency (N + 1)3/(2Tf ) of the implementations from Table 1, where T is the execution time and f the frequency of the Xeon X5650 CPU (2.67 GHz) with 12 cores.
488 |
489 | SHTns. It is remarkable that SHTns achieves an efficiency very close to 1, meaning that almost one element per clock cycle is computed for N = 511 and N = 1023. Overall, SHTns is between 2 and 10 times faster than the best alternative.
490 |
491 | 3.5. Accuracy
492 |
493 | [30] One cannot write about an SHT implementation without addressing its accuracy. The Gauss-Legendre quadrature ensures very good accuracy, at least on par with other high-quality implementations.
494 |
495 | [31] The recurrence relation we use (see section 3.2) is numerically stable, but for N ≳1500 , the value PmmðxÞ can become so small that it cannot be represented by a double-precision number anymore. To avoid this underflow problem, the code dynamically rescales the values of PnmðxÞ during the recursion, when they reach a given threshold.
496 | The number of rescalings is stored in an integer,
497 | which acts as an enhanced exponent. Our
498 | implementation of the rescaling does not impact
499 | performance negatively, as it is compensated by
500 | dynamic polar optimization: these very small values
501 | are treated as zero in the transform (equations (7)
502 | and (11)), but not in the recurrence. This technique
503 | ensures good accuracy up to N = 8191 at least, but
504 | partial transforms have been performed successfully
505 | up to N = 43,600.
506 |
507 | [32] To quantify the error, we start with random
508 | spherical harmonic coefficients Qmn with each real part and imaginary part between -1 and + 1. After
509 |
510 | a backward and forward transform (with orthonor-
511 |
512 | mal spherical harmonics), we compare the resulting coefficients Rmn with the originals Qmn . We use two different error measurements: the maximum error
513 |
514 | is defined as
515 |
516 | emax
517 |
518 | ¼
519 |
520 | max
521 | n;m
522 |
523 | Rmn
524 |
525 | À
526 |
527 | Qmn
528 |
529 | while the root mean square (rms) error is defined as
530 | erms ¼ sffiðffiNffiffiffiffiffiþffiffiffiffiffi1ffiffiÞffi2ffiðffiffiNffiffiffiffiffiþffiffiffiffiffi2ffiffiÞffiffiffiffiX ffinffiffi;ffimffiffiffiffiffiRffiffiffimnffiffiffiffiÀffiffiffiffiffiQffiffiffimnffiffiffiffi2ffiffi
531 |
532 | 756
533 |
534 | 15252027, 2013, 3, Downloaded from https://agupubs.onlinelibrary.wiley.com/doi/10.1002/ggge.20071 by Cochrane Romania, Wiley Online Library on [26/02/2023]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License
535 |
536 | Geochemistry
537 | 3 Geophysics
538 | G Geosystems
539 |
540 | SCHAEFFER: EFFICIENT SPHERICAL HARMONIC TRANSFORM
541 |
542 | 10.1002/ggge.20071
543 |
544 | vectorized on-the-fly implementations, we should be able to run spectral geodynamo simulations at N = 1023 in the next few years. Such high-resolution simulations will operate in a regime much closer to the dynamics of the Earth’s core.
545 |
546 | Acknowledgments
547 |
548 | Figure 5. Accuracy of the on-the-fly Gauss-Legendre algorithm with the default polar optimization.
549 |
550 | [36] The author thanks Alexandre Fournier and Daniel Lemire
551 | for their comments that helped to improve the paper. Some computations have been carried out at the Service Commun de Calcul Intensif de l’Observatoire de Grenoble (SCCI) and other were run on the PRACE Research Infrastructure Curie at the TGCC (grant PA1039).
552 | References
553 |
554 | The error measurements for our on-the-fly Gauss-Legendre implementation with the default polar optimization and for various truncation degrees N are shown in Figure 5. The errors steadily increase with N and are comparable to other implementations. For N < 2048, we have emax < 10À 11, which is negligible compared to other sources of errors in most numerical simulations.
555 | 4. Conclusion and Perspectives
556 | [33] Despite the many fast spherical harmonic transform algorithms published, the few with a publicly available implementation are far from the performance of a carefully written Gauss-Legendre algorithm, as implemented in the SHTns library, even for quite large truncation (N = 1023). Explicitly vectorized on-the-fly algorithms seem to be able to unleash the computing power of nowadays and future computers, without suffering too much of memory bandwidth limitations, which is an asset for multithreaded transforms.
557 | [34] The SHTns library has already been used in various demanding computations [e.g., Schaeffer et al., 2012; Augier & Lindborg, 2013; Figueroa et al., 2013]. The versatile truncation, the various normalization conventions supported, as well as the scalar and vector transform routines available for C/C++, Fortran or Python, should suit most of the current and future needs in high-performance computing involving partial differential equations in spherical geometry.
558 | [35] Thanks to the significant performance gain, as well as the much lower memory requirement of
559 |
560 | Augier, P., and E. Lindborg (2013), A new formulation of the spectral energy budget, of the atmosphere, with application to two high-resolution general circulation models, ArXiv e-prints, 1211.0607, submitted to J. Atmos. Sci.
561 | Brun, A., and M. Rempel (2009), Large scale flows in the solar convection zone, Space Sci. Rev., 144(1), 151–173, doi:10.1007/s11214-008-9454-9.
562 | Christensen, U. R., et al. (2001), A numerical dynamo benchmark, Phys. Earth and Planet. In., 128(1–4), 25–34, doi:10.1016/S0031-9201(01)00275-8.
563 | Dickson, N. G., K., Karimi, and F. Hamze (2011), Importance of explicit vectorization for CPU and GPU software performance, J. Comput. Phys., 230(13), 5383–5398, doi:10.1016/j.jcp.2011.03.041.
564 | Driscoll, J., and D. M., Healy (1994), Computing Fourier transforms and convolutions on the 2-sphere, Adv. Appl. Math., 15(2), 202–250, doi:10.1006/aama.1994.1008.
565 | Figueroa, A., N., Schaeffer, H.-C., Nataf, and D. Schmitt (2013), Modes and instabilities in magnetized spherical couette flow, J. Fluid Mech., 716, 445–469, doi:10.1017/jfm.2012.551.
566 | Frigo, M., and S. G. Johnson (2005), The design and implementation of FFTW3, P. IEEE, 93(2), 216–231, doi:10.1109/JPROC.2004.840301.
567 | Glatzmaier, G. A. (1984), Numerical simulations of stellar convective dynamos. I. the model and method, J. Comput. Phys., 55(3), 461–484, doi:10.1016/0021-9991(84)90033-0.
568 | Healy, D. M., D. N., Rockmore, P. J., Kostelec, and S. Moore (2003), Ffts for the 2-sphere-improvements and variations, J. of Fourier Anal. Appl., 9(4), 341–385, doi:10.1007/ s00041-003-0018-9.
569 | Mohlenkamp, M. J. (1999), A fast transform for spherical harmonics, J. of Fourier Anal. Appl., 5(2/3).
570 | Potts, D., G., Steidl, and M. Tasche (1998), Fast algorithms for discrete polynomial transforms, Math. Comput., 67, 1577–1590.
571 | Reinecke, M. (2011), Libpsht – algorithms for efficient spherical harmonic transforms, Astron. Astrophys., 526, A108+, doi:10.1051/0004-6361/201015906.
572 | Sakuraba, A. (1999), Effect of the inner core on the numerical solution of the magnetohydrodynamic dynamo, Phys. Earth Planet. In., 111(1-2), 105–121, doi:10.1016/S0031-9201 (98)00150-2.
573 | Sakuraba, A., and P. H. Roberts (2009), Generation of a strong magnetic field using uniform heat flux at the surface of the core, Nat. Geosci., 2(11), 802–805, doi:10.1038/ngeo643.
574 | 757
575 |
576 | 15252027, 2013, 3, Downloaded from https://agupubs.onlinelibrary.wiley.com/doi/10.1002/ggge.20071 by Cochrane Romania, Wiley Online Library on [26/02/2023]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License
577 |
578 | Geochemistry
579 | 3 Geophysics
580 | G Geosystems
581 |
582 | SCHAEFFER: EFFICIENT SPHERICAL HARMONIC TRANSFORM
583 |
584 | 10.1002/ggge.20071
585 |
586 | Schaeffer, N., D., Jault, P., Cardin, and M. Drouard (2012), On the reflection of alfvén waves and its implication for earth’s core modelling, Geophys. J. Int., 191(2), 508–516, doi:10.1111/j.1365-246X.2012.05611.x.
587 | Suda, R., and M. Takami (2002), A fast spherical harmonics transform algorithm, Math. Comput., 71(238), 703–715, doi:10.1090/S0025-5718-01-01386-2.
588 | Temme, N. M. (2011), Gauss quadrature, in Digital
589 | Library of Mathematical Functions (DLMF), chap. 3.5
590 |
591 | (v), National Institute of Standards and Technology (NIST). Tygert, M. (2008), Fast algorithms for spherical harmonic expansions, II, J. Comput. Phys., 227(8), 4260–4279, doi:10.1016/j.jcp.2007.12.019. Wicht, J., and A. Tilgner (2010), Theory and modeling of planetary dynamos, Space Sc. Rev., 152(1), 501–542, doi:10.1007/s11214-010-9638-y.
592 |
593 | 758
594 |
595 |
--------------------------------------------------------------------------------
/tests/resources/sql/storage/5KW7TMDH/.zotero-ft-info:
--------------------------------------------------------------------------------
1 | Title: ggge20071 751..758
2 | Subject: Geochem Geophys Geosyst 2013.14:751-758
3 | Creator: Arbortext Advanced Print Publisher 9.0.114/W Unicode
4 | Producer: PDFlib PLOP 2.0.0p6 (SunOS)/Acrobat Distiller 9.0.0 (Windows); modified using iText 4.2.0 by 1T3XT
5 | CreationDate: Fri Apr 12 05:07:27 2013
6 | ModDate: Sun Feb 26 00:48:57 2023
7 | Tagged: no
8 | Form: none
9 | Pages: 8
10 | Encrypted: no
11 | Page size: 612 x 792 pts (letter) (rotated 0 degrees)
12 | File size: 463114 bytes
13 | Optimized: no
14 | PDF version: 1.4
15 |
--------------------------------------------------------------------------------
/tests/resources/sql/storage/5KW7TMDH/.zotero-pdf-state:
--------------------------------------------------------------------------------
1 | {"pageIndex":0,"scale":"page-width","top":792,"left":-6,"scrollMode":0,"spreadMode":0}
--------------------------------------------------------------------------------
/tests/resources/sql/storage/5KW7TMDH/Schaeffer - 2013 - Efficient spherical harmonic transforms aimed at p.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/sql/storage/5KW7TMDH/Schaeffer - 2013 - Efficient spherical harmonic transforms aimed at p.pdf
--------------------------------------------------------------------------------
/tests/resources/sql/storage/J8FIHBUY/.zotero-ft-info:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/sql/storage/J8FIHBUY/.zotero-ft-info
--------------------------------------------------------------------------------
/tests/resources/sql/storage/J8FIHBUY/.zotero-pdf-state:
--------------------------------------------------------------------------------
1 | {"pageIndex":0,"scale":"page-width","top":845,"left":-6,"scrollMode":0,"spreadMode":0}
--------------------------------------------------------------------------------
/tests/resources/sql/storage/J8FIHBUY/Grubb - 2015 - Fractional Laplacians on domains, a development of.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/sql/storage/J8FIHBUY/Grubb - 2015 - Fractional Laplacians on domains, a development of.pdf
--------------------------------------------------------------------------------
/tests/resources/sql/storage/PIMHYJGK/.zotero-ft-cache:
--------------------------------------------------------------------------------
1 | arXiv:math/0702079v3 [math.AP] 27 Nov 2007
2 |
3 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
4 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´KELYHIDI JR.
5 | Abstract. In this paper we propose a new point of view on weak solutions of the Euler equations, describing the motion of an ideal incompressible fluid in Rn with n ≥ 2. We give a reformulation of the Euler equations as a differential inclusion, and in this way we obtain transparent proofs of several celebrated results of V. Scheffer and A. Shnirelman concerning the non-uniqueness of weak solutions and the existence of energy–decreasing solutions. Our results are stronger because they work in any dimension and yield bounded velocity and pressure.
6 |
7 | 1. Introduction
8 |
9 | Consider the Euler equations in n space dimensions, describing the motion of an ideal incompressible fluid,
10 |
11 | ∂tv + div (v ⊗ v) + ∇p − f = 0 div v = 0 .
12 |
13 | (1)
14 |
15 | Classical (i.e. sufficiently smooth) solutions of the Cauchy problem exist
16 | locally in time for sufficiently regular initial data and driving forces (see
17 | Chapter 3.2 in [16]). In two dimensions such existence results are available
18 | also for global solutions (e.g. Chapters 3.3 and 8.2 in [16] and the references
19 | therein). Classical solutions of Euler’s equations with f = 0 conserve the energy, that is t → |v(x, t)|2 dx is a constant function. Hence the energy space for (1) is L∞ t (L2x).
20 | A recurrent issue in the modern theory of PDEs is that one needs to go
21 | beyond classical solutions, in particular down to the energy space (see for instance [6, 8, 16, 25]). A divergence–free vector field v ∈ L2loc is a weak solution of (1) if
22 |
23 | v∂tϕ + v ⊗ v, ∇ϕ + ϕ · f dx dt = 0
24 |
25 | (2)
26 |
27 | for every test function ϕ ∈ Cc∞(Rnx ×Rt, Rn) with div ϕ = 0. It is well–known that then the pressure is determined up to a function depending only on time (see [28]). In the case of Euler strong motivation for considering weak solutions comes also from mathematical physics, especially the theory of turbulence laid down by Kolmogorov in 1941 [3, 11]. A celebrated criterion of Onsager related to Kolmogorov’s theory says, roughly speaking, that dissipative weak solutions cannot have a H¨older exponent greater than 1/3
28 | 1
29 |
30 | 2
31 |
32 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
33 |
34 | (see [4, 9, 10, 19]). It is therefore of interest to construct weak solutions with limited regularity.
35 | Weak solutions are not unique. In a well–known paper [21] Scheffer constructed a surprising example of a weak solution to (1) with compact support in space and time when f = 0 and n = 2. Scheffer’s proof is very long and complicated and a simpler construction was later given by Shnirelman in [22]. However, Shnirelman’s proof is still quite difficult. In this paper we obtain a short and elementary proof of the following theorem.
36 |
37 | Theorem 1.1. Let f = 0. There exists v ∈ L∞(Rnx × Rt; Rn) and p ∈ L∞(Rnx × Rt) solving (1) in the sense of distributions, such that v is not identically zero, and supp v and supp p are compact in space-time Rnx × Rt.
38 | In mathematical physics weak solutions to the Euler equations that dissipate energy underlie the Kolmogorov theory of turbulence. In another groundbreaking paper [23] Shnirelman proved the existence of L2 distributional solutions with f = 0 and energy which decreases in time. His methods are completely unrelated to those in [21] and [22]. In contrast, the following extension of his existence theorem is a simple corollary of our construction.
39 |
40 | Theorem 1.2. There exists (v, p) as in Theorem 1.1 such that, in addition: • |v(x, t)|2 dx = 1 for almost every t ∈] − 1, 1[, • v(x, t) = 0 for |t| > 1.
41 |
42 | Our method has several interesting features. First of all, our approach fits
43 |
44 | nicely in the well–known framework of L. Tartar for the analysis of oscil-
45 |
46 | lations in linear partial differential systems coupled with nonlinear point-
47 |
48 | wise constraints [7, 15, 26, 27]. Roughly speaking, Tartar’s framework
49 |
50 | amounts to a plane–wave analysis localized in physical space, in contrast
51 |
52 | with Shnirelman’s method in [22], which is based rather on a wave analy-
53 |
54 | sis in Fourier space. In combination with Gromov’s convex integration or
55 |
56 | with Baire category arguments, Tartar’s approach leads to a well under-
57 |
58 | stood mechanism for generating irregular oscillatory solutions to differential
59 |
60 | inclusions (see [14, 15, 17]).
61 |
62 | Secondly, the velocity field we construct belongs to the energy space
63 |
64 | L∞ t (L2x). This was not the case for the solutions in [21, 22], and it was a natural question whether weak solutions in the energy space were unique.
65 |
66 | Our first theorem shows that even higher summability assumptions of v do
67 |
68 | not rule out such pathologies. The pressure in [21, 22] is only a distribution
69 |
70 | solving (1). In our construction p is actually the potential–theoretic solution
71 |
72 | of
73 |
74 | − ∆p = ∂x2ixj (vivj ) − ∂xi fi .
75 |
76 | (3)
77 |
78 | However, being bounded, it has slightly better regularity than the BM O
79 |
80 | given by the classical estimates for (3).
81 |
82 | Next, our point of view reveals connections between the apparently un-
83 |
84 | related constructions of Scheffer and Shnirelman. Shnirelman considers se-
85 |
86 | quences of driving forces fk converging to 0 in some negative Sobolev space.
87 |
88 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
89 |
90 | 3
91 |
92 | In particular he shows that for a suitable choice of fk the corresponding solutions of (1) converge in L2 to a nonzero solution of (1) with f = 0. Scheffer builds his solution by iterating a certain piecewise constant construction at small scales. On the one hand both our proof and Scheffer’s proof are based on oscillations localized in physical space. On the other hand, our proof gives as an easy byproduct the following approximation result in Shnirelman’s spirit.
93 | Theorem 1.3. All the solutions (v, p) constructed in the proofs of Theorem 1.1 and in Theorem 1.2 have the following property. There exist three sequences {vk}, {fk}, {pk} ⊂ Cc∞ solving (1) such that
94 | • fk converges to 0 in H−1, • vk ∞ + pk ∞ is uniformly bounded, • (vk, pk) → (v, p) in Lq for every q < ∞.
95 | Our results give interesting information on which kind of additional (entropy) condition could restore uniqueness of solutions. As already remarked, belonging to the energy space is not sufficient. In fact, in view of our method of construction, there is strong evidence that neither energy–decreasing nor energy–preserving solutions are unique. In a forthcoming paper we plan to investigate this issue, and also the class of initial data for which our method yields energy–decreasing solutions.
96 | The rest of the paper is organized as follows. In Section 2 we carry out the plane wave analysis of the Euler equations in the spirit of Tartar, and we formulate the core of our construction (Proposition 2.2). In Section 3 we prove Proposition 2.2. In Section 4 we show how our main results follow from the Proposition. We emphasize that the concluding argument in Section 4 appeals to the – by now standard – methods for solving differential inclusions, either by appealing to the Baire category theorem [1, 2, 5, 13], or by the more explicit convex integration method [12, 17, 18]. In our opinion, the Baire category argument developed in [14] and used in Section 4 is, for the purposes of this paper, the most efficient and elegant tool. However, we include in Section 5 an alternative proof which follows the convex integration approach, as it makes easier to ”visualize” the solutions constructed in this paper.
97 | In fact we believe that for n ≥ 3 a suitable modification of the original approach of Gromov (see [12]) would also work, yielding solutions which are even continuous (work in progress).
98 |
99 | 2. Plane wave analysis of Euler’s equations
100 |
101 | We start by briefly explaining Tartar’s framework [26]. One considers
102 |
103 | nonlinear PDEs that can be expressed as a system of linear PDEs (conser-
104 |
105 | vation laws)
106 |
107 | m
108 |
109 | Ai∂iz = 0
110 |
111 | (4)
112 |
113 | i=1
114 |
115 | 4
116 |
117 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
118 |
119 | coupled with a pointwise nonlinear constraint (constitutive relations)
120 |
121 | z(x) ∈ K ⊂ Rd a.e.,
122 |
123 | (5)
124 |
125 | where z : Ω ⊂ Rm → Rd is the unknown state variable. The idea is then to consider plane wave solutions to (4), that is, solutions of the form
126 |
127 | z(x) = ah(x · ξ),
128 |
129 | (6)
130 |
131 | where h : R → R. The wave cone Λ is given by the states a ∈ Rd such that for any choice of the profile h the function (6) solves (4), that is,
132 |
133 | m
134 |
135 | Λ := a ∈ Rd : ∃ξ ∈ Rm \ {0} with
136 |
137 | ξiAia = 0 .
138 |
139 | (7)
140 |
141 | i=1
142 |
143 | The oscillatory behavior of solutions to the nonlinear problem is then deter-
144 |
145 | mined by the compatibility of the set K with the cone Λ.
146 |
147 | The Euler equations can be naturally rewritten in this framework. The
148 |
149 | domain is Rm = Rn+1, and the state variable z is defined as z = (v, u, q),
150 |
151 | where
152 |
153 | q
154 |
155 | =p+
156 |
157 | 1 n
158 |
159 | |v|2
160 |
161 | ,
162 |
163 | and
164 |
165 | u=v⊗v−
166 |
167 | 1 n
168 |
169 | |v|2
170 |
171 | In,
172 |
173 | so that u is a symmetric n × n matrix with vanishing trace and In denotes the n × n identity matrix. From now on the linear space of symmetric n × n
174 |
175 | matrices will be denoted by Sn and the subspace of trace–free symmetric
176 |
177 | matrices by S0n. The following lemma is straightforward.
178 |
179 | Lemma 2.1. Suppose v ∈ L∞(Rnx × Rt; Rn), u ∈ L∞(Rnx × Rt; S0n), and q ∈ L∞(Rnx × Rt) solve
180 |
181 | ∂tv + div u + ∇q = 0, div v = 0,
182 |
183 | (8)
184 |
185 | in the sense of distributions. If in addition
186 |
187 | u
188 |
189 | =
190 |
191 | v
192 |
193 | ⊗
194 |
195 | v
196 |
197 | −
198 |
199 | 1 n
200 |
201 | |v|2
202 |
203 | In
204 |
205 | a.e. in Rnx × Rt,
206 |
207 | (9)
208 |
209 | then
210 |
211 | v
212 |
213 | and
214 |
215 | p :=
216 |
217 | q−
218 |
219 | 1 n
220 |
221 | |v|2
222 |
223 | are
224 |
225 | a
226 |
227 | solution
228 |
229 | to
230 |
231 | (1)
232 |
233 | with
234 |
235 | f
236 |
237 | ≡ 0.
238 |
239 | Conversely,
240 |
241 | if
242 |
243 | v
244 |
245 | and
246 |
247 | p
248 |
249 | solve
250 |
251 | (1)
252 |
253 | distributionally,
254 |
255 | then
256 |
257 | v,
258 |
259 | u
260 |
261 | :=
262 |
263 | v⊗v−
264 |
265 | 1 n
266 |
267 | |v|2In
268 |
269 | and
270 |
271 | q
272 |
273 | :=
274 |
275 | p+
276 |
277 | 1 n
278 |
279 | |v|2
280 |
281 | solve (8) and (9).
282 |
283 | Consider the (n + 1) × (n + 1) symmetric matrix in block form
284 |
285 | U=
286 |
287 | u + qIn v
288 |
289 | v 0
290 |
291 | ,
292 |
293 | (10)
294 |
295 | where In is the n × n identity matrix. Notice that by introducing new coordinates y = (x, t) ∈ Rn+1 the equation (8) becomes simply
296 |
297 | divyU = 0.
298 |
299 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
300 |
301 | 5
302 |
303 | Here, as usual, a divergence–free matrix field is a matrix of functions with rows that are divergence–free vectors. Therefore the wave cone corresponding to (8) is given by
304 |
305 | Λ=
306 |
307 | (v, u, q) ∈ Rn × S0n × R : det
308 |
309 | u + qIn v
310 |
311 | v 0
312 |
313 | =0
314 |
315 | .
316 |
317 | Remark 1. A simple linear algebra computation shows that for every v ∈ Rn and u ∈ S0n there exists q ∈ R such that (v, u, q) ∈ Λ, revealing that the wave cone is very large. Indeed, let V ⊥ ⊂ Rn be the linear space orthogonal to v and consider on V ⊥ the quadratic form ξ → ξ · uξ. Then, det U = 0 if and
318 | only if −q is an eigenvalue of this quadratic form.
319 |
320 | In order to exploit this fact for constructing irregular solutions to the nonlinear system, one needs plane wave–like solutions to (8) which are localized in space. Clearly an exact plane–wave as in (6) has compact support only if it is identically zero. Therefore this can only be done by introducing an error in the range of the wave, deviating from the line spanned by the wave state a ∈ Rd. However, this error can be made arbitrarily small. This is the content of the following proposition, which is the building block of our construction.
321 |
322 | Proposition 2.2 (Localized plane waves). Let a = (v0, u0, q0) ∈ Λ with v0 = 0, and denote by σ the line segment in Rn × S0n × R joining the points −a and a. For every ε > 0 there exists a smooth solution (v, u, q) of (8) with the properties:
323 | • the support of (v, u, q) is contained in B1(0) ⊂ Rnx × Rt, • the image of (v, u, q) is contained in the ε–neighborhood of σ, • |v(x, t)| dx dt ≥ α|v0|,
324 | where α > 0 is a dimensional constant.
325 |
326 | 3. Localized plane waves
327 |
328 | For the proof of Proposition 2.2 there are two main points. Firstly, we appeal to a particular large group of symmetries of the equations in order to reduce the problem to some special Λ-directions. Secondly, to achieve a cut-off which preserves the linear equations (8), we introduce a suitable potential.
329 |
330 | Definition 3.1. We denote by M the set of symmetric (n + 1) × (n + 1) matrices A such that A(n+1)(n+1) = 0. Clearly, the map
331 |
332 | Rn × S0n × R ∋ (v, u, q)
333 |
334 | →
335 |
336 | U=
337 |
338 | u + qIn v
339 |
340 | v 0
341 |
342 | ∈M
343 |
344 | (11)
345 |
346 | is a linear isomorphism.
347 |
348 | As already observed, in the variables y = (x, t) ∈ Rn+1, the equation (8) is equivalent to div U = 0. Therefore Proposition 2.2 follows immediately from
349 |
350 | 6
351 |
352 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
353 |
354 | Proposition 3.2. Let U ∈ M be such that det U = 0 and U en+1 = 0, and consider the line segment σ with endpoints −U and U . Then there exists a constant α > 0 such that for any ε > 0 there exists a smooth divergence–free matrix field U : Rn+1 → M with the properties
355 | (p1) supp U ⊂ B1(0), (p2) dist (U (y), σ) < ε for all y ∈ B1(0), (p3) |U (y)en+1|dy ≥ α|U en+1|,
356 | where α > 0 is a dimensional constant.
357 |
358 | The proof of Proposition 3.2 relies on two lemmas. The first deals with the symmetries of the equations.
359 |
360 | Lemma 3.3 (The Galilean group). Let G be the subgroup of GLn+1(R) defined by
361 |
362 | A ∈ R(n+1)×(n+1) : det A = 0, Aen+1 = en+1 .
363 |
364 | (12)
365 |
366 | For every divergence–free map U : Rn+1 → M and every A ∈ G the map
367 |
368 | V (y) := At · U (A−ty) · A
369 |
370 | is also a divergence–free map V : Rn+1 → M.
371 |
372 | The second deals with the potential.
373 |
374 | Lemma 3.4 (Potential in the general case). Let Eikjl ∈ C∞(Rn+1) be functions for i, j, k, l = 1, . . . , n + 1 so that the tensor E is skew–symmetric in
375 |
376 | ij and kl, that is
377 |
378 | Eikjl = −Eiljk = −Ejkil = Ejlki .
379 |
380 | (13)
381 |
382 | Then
383 |
384 | Uij
385 |
386 | =
387 |
388 | L(E)
389 |
390 | =
391 |
392 | 1 2
393 |
394 | ∂k2l(Ekilj + Ekjli)
395 |
396 | k,l
397 |
398 | (14)
399 |
400 | is symmetric and divergence–free. If in addition
401 |
402 | E((nn++11))ij = 0
403 |
404 | for every i and j,
405 |
406 | (15)
407 |
408 | then U takes values in M.
409 |
410 | Remark 2. A suitable potential in the case n = 2 can be obtained in a more direct way. Indeed, let w ∈ C∞(R3, R3) be a divergence–free vector field and consider the map U : R3 → M given by
411 |
412 | ∂2w1
413 |
414 | U
415 |
416 | =
417 |
418 |
419 |
420 | 1 21 2
421 |
422 | ∂2w2 ∂2w3
423 |
424 | −
425 |
426 | 1 2
427 |
428 | ∂1w1
429 |
430 | 1 2
431 |
432 | ∂2
433 |
434 | w2
435 |
436 | −
437 |
438 | 1 2
439 |
440 | ∂1w1
441 |
442 | −∂1w2
443 |
444 | −
445 |
446 | 1 2
447 |
448 | ∂1w3
449 |
450 | −21 ∂212∂w13w3
451 |
452 | .
453 |
454 | 0
455 |
456 | (16)
457 |
458 | Then it can be readily checked that U is divergence–free. Moreover, w is the
459 | curl of a vector field ω. However, this is just a particular case of Lemma 3.4. Indeed, given E as in the Lemma define the tensor Dikj = l ∂lEikjl. Note
460 |
461 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
462 |
463 | 7
464 |
465 | that D is skew–symmetric in ij and for each ij, the vector (Dikj)k=1,...,n+1 is divergence–free. Moreover,
466 |
467 | Uij
468 |
469 | =
470 |
471 | 1 2
472 |
473 | ∂k(Dki j + Dkji) .
474 |
475 | k
476 |
477 | Then the vector field w above is simply the special choice where D1k2 = −D2k1 = wk and all other D’s are zero, and a corresponding relation can be found for E and ω.
478 |
479 | The proofs of the two Lemmas will be postponed until the end of the section and we now come to the proof of the Proposition.
480 |
481 | Proof of Proposition 3.2. Step 1. First we treat the case when U ∈ M is
482 |
483 | such that
484 |
485 | U e1 = 0, U en+1 = 0.
486 |
487 | (17)
488 |
489 | Let
490 |
491 | Eij11
492 |
493 | =
494 |
495 | −E1ji1
496 |
497 | =
498 |
499 | −Ei11j
500 |
501 | =
502 |
503 | E11ij
504 |
505 | =
506 |
507 | U
508 |
509 | ij
510 |
511 | sin(N y1) N2
512 |
513 | (18)
514 |
515 | and all the other entries equal to 0. Note that by our assumption U ij = 0 whenever one index is 1 or both of them are n + 1. This ensures that the
516 |
517 | tensor E is well defined and satisfies the properties of Lemma 3.4.
518 |
519 | We remark that in the case n = 2 the matrix U takes necessarily the form
520 |
521 | 0 0 0
522 |
523 | U =0 a b
524 |
525 | (19)
526 |
527 | 0b 0
528 |
529 | with b = 0, and we can use the potential of Remark 2 by simply setting
530 |
531 | w
532 |
533 | =
534 |
535 | 1 N
536 |
537 | (0,
538 |
539 | a
540 |
541 | cos(N
542 |
543 | y1),
544 |
545 | 2b
546 |
547 | cos(N
548 |
549 | y1))
550 |
551 | ,
552 |
553 | ω
554 |
555 | =
556 |
557 | 1 N2
558 |
559 | (0,
560 |
561 | 2b
562 |
563 | sin(N
564 |
565 | y1
566 |
567 | ),
568 |
569 | −a
570 |
571 | sin(N
572 |
573 | y1))
574 |
575 | .
576 |
577 | We come back to the general case. Let E be defined as in (18), fix a
578 |
579 | smooth cutoff function ϕ such that
580 |
581 | • |ϕ| ≤ 1,
582 | • ϕ = 1 on B1/2(0), • supp (ϕ) ⊂ B1(0),
583 |
584 | and consider the map
585 |
586 | U = L(ϕE).
587 |
588 | Clearly, U is smooth and supported in B1(0). By Lemma 3.4, U is M–valued and divergence–free. Moreover
589 |
590 | U (y) = U sin(N y1) for y ∈ B1/2(0), and in particular
591 |
592 | |U (y)en+1|dy ≥ |U en+1|
593 |
594 | | sin(N y1)| dy ≥ 2α|U en+1|,
595 |
596 | B1/2 (0)
597 |
598 | 8
599 |
600 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
601 |
602 | for some positive dimensional constant α = α(n) for sufficiently large N . Finally, observe that
603 | U − ϕU˜ = L(ϕE) − ϕL(E)
604 |
605 | is a sum of products of first–order derivatives of ϕ with first–order derivatives of components of E and of second–order derivatives of ϕ with components of E. Thus,
606 |
607 | U − ϕU˜
608 |
609 | ∞
610 |
611 | ≤
612 |
613 | C
614 |
615 | ϕ
616 |
617 | C2
618 |
619 | E
620 |
621 | C1
622 |
623 | ≤
624 |
625 | C′ N
626 |
627 | ϕ
628 |
629 | C2 ,
630 |
631 | and by choosing N sufficiently large we obtain U − ϕU˜ ∞ < ε. On the other hand, since |ϕ| ≤ 1 and U˜ takes values in σ, the image of ϕU˜ is also contained in σ. This shows that the image of U is contained in the ε–neighborhood of σ.
632 |
633 | Step 2. We treat the general case by reducing to the situation above. Let U ∈ M be as in the Proposition, so that
634 |
635 | U f = 0, U en+1 = 0,
636 | where f ∈ Rn+1 \ {0} is such that {f, en+1} are linearly independent. Let f1, . . . , fn+1 be a basis for Rn+1 such that f1 = f and fn+1 = en+1 and consider the matrix A such that
637 |
638 | Aei = fi for i = 1, . . . , n + 1. Then A ∈ G (cf. with the definition of G given in Lemma 3.3), and the map
639 |
640 | T : X → (A−1)tXA−1
641 |
642 | (20)
643 |
644 | is a linear isomorphism of Rn+1. Set
645 |
646 | V = AtU A,
647 |
648 | (21)
649 |
650 | so that V ∈ M satisfies
651 |
652 | V e1 = 0, V en+1 = 0.
653 | Given ε > 0, using Step 1 we construct a smooth map V : Rn+1 → M supported in B1(0) with the image lying in the T −1ε–neighborhood of the line segment τ with endpoints −V and V , and such that
654 |
655 | V (y) = V sin(N y1). Let U be the M–valued map
656 | U (y) = (A−1)tV (Aty)A−1.
657 |
658 | By our discussion above the isomorphism T : X → (A−1)tXA−1 maps the line segment τ onto σ. Therefore:
659 | • U is supported in A−t(B1(0)) and it is smooth, • U is divergence–free thanks to Lemma 3.3, • U takes values in an ε–neighborhood of the segment σ,
660 |
661 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
662 |
663 | 9
664 |
665 | and furthermore
666 |
667 | |U (y)en+1|dy =
668 |
669 | |A−tV (Aty)en+1|dy
670 |
671 | A−t (B1 (0))
672 |
673 | A−t (B1 (0))
674 |
675 | =
676 |
677 | B1 (0)
678 |
679 | |A−tV
680 |
681 | (z)en+1|
682 |
683 | |
684 |
685 | dz det At|
686 |
687 | ≥
688 |
689 | 2α|A−tV en+1| | det A|
690 |
691 | =
692 |
693 | |
694 |
695 | 2α det A|
696 |
697 | |U
698 |
699 | en+1
700 |
701 | |.
702 |
703 | (22)
704 |
705 | To complete the proof we appeal to a standard covering/rescaling argument.
706 | That is, we can find a finite number of points yk ∈ B1(0) and radii rk > 0 so that the rescaled and translated sets A−t(Brk (yk)) are pairwise disjoint, all contained in B1(0), and
707 |
708 | A−t(Brk (yk))
709 |
710 | ≥
711 |
712 | 1 2
713 |
714 | |B1(0)|.
715 |
716 | (23)
717 |
718 | k
719 |
720 | Let
721 |
722 | Uk (y )
723 |
724 | =
725 |
726 | U
727 |
728 | (
729 |
730 | y−yk rk
731 |
732 | )
733 |
734 | and
735 |
736 | U˜
737 |
738 | =
739 |
740 | k Uk. Then U˜ : Rn+1 → M is smooth,
741 |
742 | clearly satisfies (p1) and (p2), and
743 |
744 | |U˜ (y)en+1|dy =
745 |
746 | |Uk (y )en+1 |dy
747 | k A−tBrk (yk)
748 |
749 | (22)
750 | ≥
751 |
752 | k
753 |
754 | 2α|U
755 |
756 | en+1
757 |
758 | ||
759 |
760 | det
761 |
762 | A|−1
763 |
764 | |Brk (yk)| |B1(0)|
765 |
766 | =
767 |
768 | 2α|U en+1|
769 |
770 | k A−t(Brk (yk)) |B1(0)|
771 |
772 | (23)
773 | ≥ α|U en+1|.
774 |
775 | This completes the proof.
776 |
777 | Proof of Lemma 3.3. First of all we check that whenever B ∈ M, then AtBA ∈ M for all A ∈ G. Indeed, AtBA is symmetric, and since A satisfies
778 | Aen+1 = en+1, we have
779 |
780 | (AtBA)(n+1)(n+1) = en+1 · AtBAen+1 = Aen+1 · BAen+1 = en+1 · Ben+1 = B(n+1)(n+1) = 0.
781 |
782 | (24)
783 |
784 | Now, let A, U and V be as in the statement. The argument above shows
785 | that V is M–valued. It remains to check that if U is divergence–free, then V is also divergence–free. To this end let φ ∈ Cc∞(Rn+1; Rn+1) be a compactly supported test function and consider φ˜ ∈ Cc∞(Rn+1; Rn+1) defined by
786 |
787 | φ˜(x) = Aφ(Atx).
788 |
789 | 10
790 |
791 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
792 |
793 | Then ∇φ˜(x) = A∇φ(Atx)At, and by a change of variables we obtain
794 |
795 | tr V(y)∇φ(y) dy = tr AtU(A−ty)A∇φ(y) dy
796 |
797 | = tr U(A−ty)A∇φ(y)At dy
798 |
799 | = tr U(x)A∇φ(Atx)At (det A)−1dx
800 |
801 | =(det A)−1 tr U(x)∇φ˜(x) dx = 0, since U is divergence–free. But this implies that V is also divergence-free.
802 |
803 | Proof of Lemma 3.4. First of all, U is clearly symmetric and U(n+1)(n+1) = 0. Hence U takes values in M. To see that U is divergence–free, we calculate
804 |
805 | ∂j Uij
806 |
807 | =
808 |
809 | 1 2
810 |
811 | ∂j3kl(Ekilj + Ekjli)
812 |
813 | j
814 |
815 | k,l
816 |
817 | =
818 |
819 | 1 2
820 |
821 | ∂l
822 |
823 | ∂j2k Ekilj
824 |
825 | +
826 |
827 | 1 2
828 |
829 | ∂k
830 |
831 | l
832 |
833 | jk
834 |
835 | k
836 |
837 | ∂j2lEkjli
838 | jl
839 |
840 | (1=3) 0 .
841 |
842 | This completes the proof of the lemma.
843 |
844 | 4. Proof of the main results
845 | For clarity we now state the precise form of our main result. Theorems 1.1, 1.2 and 1.3 are direct corollaries.
846 | Theorem 4.1. Let Ω ⊂ Rnx × Rt be a bounded open domain. There exists (v, p) ∈ L∞(Rnx × Rt) solving the Euler equations
847 | ∂tv + div (v ⊗ v) + ∇p = 0 div v = 0 ,
848 | such that • |v(x, t)| = 1 for a.e. (x, t) ∈ Ω, • v(x, t) = 0 and p(x, t) = 0 for a.e. (x, t) ∈ (Rnx × Rt) \ Ω.
849 | Moreover, there exists a sequence of functions (vk, pk, fk) ∈ Cc∞(Ω) such that
850 | ∂tvk + div (vk ⊗ vk) + ∇pk = fk div vk = 0 ,
851 | and • fk converges to 0 in H−1, • vk ∞ + pk ∞ is uniformly bounded, • (vk, pk) → (v, p) in Lq for every q < ∞.
852 |
853 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
854 |
855 | 11
856 |
857 | We remark that the statements of Theorem 1.1 and Theorem 1.3 are just subsets of the statement of Theorem 4.1. As for Theorem 1.2, note that it suffices to choose, for instance, Ω = Br(0)×] − 1, 1[, where Br(0) is the ball of Rn with volume 1.
858 | We recall from Lemma 2.1 that for the first half of the theorem it suffices to prove that there exist
859 | (v, u, q) ∈ L∞(Rnx × Rt; Rn × S0n × R)
860 | with support in Ω, such that |v| = 1 a.e. in Ω and (8) and (9) are satisfied. In Proposition 2.2 we constructed compactly supported solutions (v, u, q) to (8). The point is thus to find solutions which satisfy in addition the pointwise constraint (9). The main idea is to consider the sets
861 |
862 | K=
863 |
864 | (v, u)
865 |
866 | ∈
867 |
868 | Rn × S0n
869 |
870 | :
871 |
872 | u
873 |
874 | =
875 |
876 | v⊗v−
877 |
878 | 1 n
879 |
880 | |v|2
881 |
882 | In
883 |
884 | ,
885 |
886 | |v| = 1
887 |
888 | ,
889 |
890 | (25)
891 |
892 | and
893 |
894 | U = int (Kco × [−1, 1]),
895 |
896 | (26)
897 |
898 | where int denotes the topological interior of the set in Rn × S0n × R, and Kco denotes the convex hull of K. Thus, a triple (v, u, q) solving (8) and taking values in the convex extremal points of U is indeed a solution to (9). We will prove that 0 ∈ U, and therefore there exist plane waves taking values in U. The goal is to add them so to get an infinite sum
899 |
900 | ∞
901 | (v, u, q) = (vi, ui, qi)
902 | i=1
903 |
904 | with the properties that
905 |
906 | • the partial sums ki=0(vi, ui, qi) take values in U , • (v, u, q) is supported in Ω, • (v, u, q) takes values in the convex extremal points of U a.e. in Ω, • (v, u, q) solves the linear partial differential equations (8).
907 |
908 | There are two important reasons why this construction is possible. First of all, since the wave cone Λ is very large, we can always get closer and closer to the extremal point of U with the sequence (vk, uk, pk). Secondly, because the waves are localized in space–time, by choosing the supports smaller and smaller we can achieve strong convergence of the sequence. In view of Lemma 2.1 this gives the solution of Euler that we we are looking for. The partial sums give the approximating sequence of the theorem.
909 |
910 | This sketch of the proof is philosophically closer to the method of convex integration, where the difficulty is to ensure strong convergence of the partial sums. The Baire category argument avoids this difficulty by introducing a metric for the space of solutions to (8) with values in U, and proving that in its closure a generic element takes values in the convex extreme points. An interesting corollary of the Baire category argument is that, within the class of solutions to the Euler equations with driving force in some particular
911 |
912 | 12
913 |
914 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
915 |
916 | bounded subset of H−1, the typical (in the sense of category) element has the properties of Theorem 4.1 .
917 | We split the proof of Theorem 4.1 into several lemmas and a short concluding argument, which is given at the beginning of Section 4.3. For the purpose of this section, we could have presented a shorter proof, avoiding Lemma 4.3 and without giving the explicit bound (30) of Lemma 4.6. However, these statements will be needed in the convex integration proof of Section 5.
918 |
919 | 4.1. The geometric setup.
920 |
921 | Lemma 4.2. Let K and U be defined as in (25) and (26), i.e.
922 |
923 | K=
924 |
925 | (v, u)
926 |
927 | ∈
928 |
929 | Sn−1
930 |
931 | ×
932 |
933 | S0n
934 |
935 | :
936 |
937 | u
938 |
939 | =
940 |
941 | v
942 |
943 | ⊗v
944 |
945 | −
946 |
947 | In n
948 |
949 | .
950 |
951 | Then 0 ∈ int Kco and hence 0 ∈ U .
952 |
953 | Proof. Let µ be the Haar measure on Sn−1 and consider the linear map
954 |
955 | T : C(Sn−1) → Rn × S0n, Clearly, if
956 |
957 | φ→
958 | Sn−1
959 |
960 | v,
961 |
962 | v
963 |
964 | ⊗
965 |
966 | v
967 |
968 | −
969 |
970 | In n
971 |
972 | φ(v) dµ .
973 |
974 | φ ≥ 0 and
975 |
976 | φ dµ = 1 ,
977 |
978 | (27)
979 |
980 | Sn−1
981 |
982 | then T (φ) ∈ Kco. Notice that
983 |
984 | T (1) =
985 |
986 | v, v ⊗ v − In
987 |
988 | Sn−1
989 |
990 | n
991 |
992 | dµ = 0,
993 |
994 | and hence 0 ∈ Kco. Moreover, whenever ψ ∈ C(Sn−1) is such that
995 |
996 | α = 1−
997 |
998 | ψ dµ ≥ ψ C(Sn−1),
999 |
1000 | Sn−1
1001 |
1002 | (28)
1003 |
1004 | φ = α + ψ satisfies (27) and hence T (ψ) = T (φ) ∈ Kco. Since (28) holds
1005 |
1006 | whenever ψ C(Sn−1) < 1/2, it suffices to show that T is surjective to prove that Kco contains a neighborhood of 0.
1007 | The surjectivity of T follows from orthogonality in L2(Sn−1). Indeed,
1008 |
1009 | letting φ = vi for each i, we obtain
1010 |
1011 | T (φ) = β1(ei, 0), where β1 =
1012 |
1013 | v12dµ.
1014 |
1015 | Sn−1
1016 |
1017 | Furthermore, setting φ = vivj with i = j, we obtain
1018 |
1019 | T (φ) = β2 0, ei ⊗ ej + ej ⊗ ei , where β2 =
1020 |
1021 | v12v22dµ.
1022 |
1023 | Sn−1
1024 |
1025 | Finally,
1026 |
1027 | setting
1028 |
1029 | φ
1030 |
1031 | =
1032 |
1033 | vi2
1034 |
1035 | −
1036 |
1037 | 1 n
1038 |
1039 | we
1040 |
1041 | obtain
1042 |
1043 | T (φ) = β3
1044 |
1045 | 0,
1046 |
1047 | ei
1048 |
1049 | ⊗
1050 |
1051 | ei
1052 |
1053 | −
1054 |
1055 | (n
1056 |
1057 | 1 −
1058 |
1059 | 1)
1060 |
1061 | ej ⊗ ej ,
1062 |
1063 | j=i
1064 |
1065 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
1066 |
1067 | 13
1068 |
1069 | where
1070 |
1071 | β3 =
1072 |
1073 | Sn−1
1074 |
1075 | v12
1076 |
1077 | −
1078 |
1079 | 1 n
1080 |
1081 | 2
1082 | dµ.
1083 |
1084 | This shows that elements, hence
1085 |
1086 | the image of T a basis for Rn
1087 |
1088 | contains × S0n.
1089 |
1090 | n+
1091 |
1092 | 1 2
1093 |
1094 | n(n+1)−1
1095 |
1096 | linearly
1097 |
1098 | independent
1099 |
1100 | Lemma 4.3. There exists a dimensional constant C > 0 such that for any (v, u, q) ∈ U there exists (v¯, u¯) ∈ Rn × S0n such that (v¯, u¯, 0) ∈ Λ, the line segment with endpoints (v, u, q) ± (v¯, u¯, 0) is contained in U, and
1101 |
1102 | |v¯| ≥ C(1 − |v|2).
1103 |
1104 | Proof. Let z = (v, u) ∈ int Kco. By Carath´eodory’s theorem (v, u) lies in the interior of a simplex in Rn × S0n spanned by elements of K. In other words
1105 | N +1
1106 | z = λizi,
1107 | i=1
1108 |
1109 | where λi ∈ ]0, 1[ , zi = (vi, ui) ∈ K,
1110 |
1111 | N +1 i=1
1112 |
1113 | λi
1114 |
1115 | =
1116 |
1117 | 1,
1118 |
1119 | and
1120 |
1121 | N
1122 |
1123 | =
1124 |
1125 | n(n + 3)/2 − 1
1126 |
1127 | is
1128 |
1129 | the dimension of Rn × S0n. Assume that the coefficients are ordered so that
1130 |
1131 | λ1 = maxi λi. Then for any j > 1
1132 |
1133 | z
1134 |
1135 | ±
1136 |
1137 | 1 2
1138 |
1139 | λj
1140 |
1141 | (zj
1142 |
1143 | − z1)
1144 |
1145 | ∈
1146 |
1147 | int
1148 |
1149 | K co.
1150 |
1151 | Indeed,
1152 |
1153 | z
1154 |
1155 | ±
1156 |
1157 | 1 2
1158 |
1159 | λj
1160 |
1161 | (zj
1162 |
1163 | − z1) =
1164 |
1165 | µizi,
1166 |
1167 | i
1168 |
1169 | where
1170 |
1171 | µ1
1172 |
1173 | = λ1 ∓
1174 |
1175 | 1 2
1176 |
1177 | λj
1178 |
1179 | ,
1180 |
1181 | µj
1182 |
1183 | =
1184 |
1185 | λj
1186 |
1187 | ±
1188 |
1189 | 1 2
1190 |
1191 | λj
1192 |
1193 | and
1194 |
1195 | µi
1196 |
1197 | = λi
1198 |
1199 | for
1200 |
1201 | i
1202 |
1203 | ∈/
1204 |
1205 | {1, j}.
1206 |
1207 | It
1208 |
1209 | is
1210 |
1211 | easy
1212 |
1213 | to
1214 |
1215 | see that µi ∈ ]0, 1[ for all i = 1 . . . N + 1.
1216 |
1217 | On the other hand z − z1 =
1218 |
1219 | N +1 i=2
1220 |
1221 | λi(zi
1222 |
1223 | −
1224 |
1225 | z1),
1226 |
1227 | so
1228 |
1229 | that
1230 |
1231 | in
1232 |
1233 | particular
1234 |
1235 | |v
1236 |
1237 | −
1238 |
1239 | v1|
1240 |
1241 | ≤
1242 |
1243 | N
1244 |
1245 | max
1246 | i=2...N +1
1247 |
1248 | λi|vi
1249 |
1250 | −
1251 |
1252 | v1|
1253 |
1254 | Let j > 1 be such that λj|vj − v1| = maxi=2...N+1 λi|vi − v1|, and let
1255 |
1256 | (v¯, u¯)
1257 |
1258 | =
1259 |
1260 | 1 2
1261 |
1262 | λj
1263 |
1264 | (zj
1265 |
1266 | −
1267 |
1268 | z1).
1269 |
1270 | The line segment with endpoints (v, u) ± (v¯, u¯) is contained in the interior of Kco and hence also the line segment (v, u, q) ± (v¯, u¯, 0) is contained in U .
1271 | Furthermore
1272 |
1273 | 1 4N
1274 |
1275 | (1
1276 |
1277 | −
1278 |
1279 | |v|2)
1280 |
1281 | ≤
1282 |
1283 | 1 2N
1284 |
1285 | (1
1286 |
1287 | −
1288 |
1289 | |v|)
1290 |
1291 | ≤
1292 |
1293 | 1 2N
1294 |
1295 | (|v
1296 |
1297 | −
1298 |
1299 | v1|)
1300 |
1301 | ≤
1302 |
1303 | |v¯|.
1304 |
1305 | 14
1306 |
1307 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
1308 |
1309 | Finally, we show that (v¯, u¯, 0) ∈ Λ. This amounts to showing that whenever a, b ∈ Sn−1, the matrix
1310 |
1311 | a
1312 |
1313 | ⊗
1314 |
1315 | a
1316 |
1317 | −
1318 |
1319 | In n
1320 |
1321 | a
1322 |
1323 | a 0
1324 |
1325 | −
1326 |
1327 | b
1328 |
1329 | ⊗
1330 |
1331 | b
1332 |
1333 | −
1334 |
1335 | In n
1336 |
1337 | b
1338 |
1339 | b 0
1340 |
1341 | has zero determinant and hence lies in the wave cone Λ defined in (7). Let
1342 |
1343 | P ∈ GLn(R) with P a = e1 and P b = e2. Note that
1344 |
1345 | P0 01
1346 |
1347 | a⊗a a a0
1348 |
1349 | Pt 0
1350 |
1351 | 0 1
1352 |
1353 | =
1354 |
1355 | Pa ⊗ Pa Pa
1356 |
1357 | Pa 1
1358 |
1359 | ,
1360 |
1361 | so that it suffices to check the determinant of
1362 |
1363 | e1 ⊗ e1 e1
1364 |
1365 | e1 0
1366 |
1367 | −
1368 |
1369 | e2 ⊗ e2 e2
1370 |
1371 | e2 0
1372 |
1373 | .
1374 |
1375 | Since e1 + e2 − en+1 is in the kernel of this matrix, it has indeed determinant zero. This completes the proof.
1376 |
1377 | 4.2. The functional setup. We define the complete metric space X as follows. Let
1378 | X0 := (v, u, q) ∈ C∞(Rnx × Rt) : (i), (ii) and (iii) below hold
1379 | (i) supp (v, u, q) ⊂ Ω, (ii) (v, u, q) solves (8) in Rnx × Rt, (iii) (v(x, t), u(x, t), q(x, t)) ∈ U for all (x, t) ∈ Rnx × Rt. We equip X0 with the topology of L∞-weak* convergence of (v, u, q) and we let X be the closure of X0 in this topology.
1380 | Lemma 4.4. The set X with the topology of L∞ weak* convergence is a nonempty compact metrizable space. Moreover, if (v, u, q) ∈ X is such that
1381 |
1382 | |v(x, t)| = 1 for almost every (x, t) ∈ Ω,
1383 |
1384 | then
1385 |
1386 | v
1387 |
1388 | and
1389 |
1390 | p
1391 |
1392 | :=
1393 |
1394 | q
1395 |
1396 | −
1397 |
1398 | 1 n
1399 |
1400 | |v|2
1401 |
1402 | is a weak solution
1403 |
1404 | of
1405 |
1406 | (1) in Rnx × Rt
1407 |
1408 | such that
1409 |
1410 | v(x, t) = 0 and p(x, t) = 0 for all (x, t) ∈ Rnx × Rt \ Ω.
1411 |
1412 | Proof. In Lemma 4.2 we showed that 0 ∈ U, hence X is nonempty. Moreover, X is a bounded and closed subset of L∞(Ω), hence with the weak* topology
1413 | it becomes a compact metrizable space. Since U is a compact convex set, any (v, u, q) ∈ X satisfies
1414 |
1415 | supp (v, u, q) ⊂ Ω, (v, u, q) solves (8) and takes values in U.
1416 |
1417 | In particular (v, u)(x, t) ∈ Kco almost everywhere. Finally, observe also that if (v, u)(x, t) ∈ Kco, then
1418 |
1419 | (v, u)(x, t) ∈ K if and only if |v(x, t)| = 1.
1420 |
1421 | In light of Lemma 2.1 this concludes the proof.
1422 |
1423 | Fix a metric d∗∞ inducing the weak* topology of L∞ in X, so that (X, d∗∞) is a complete metric space.
1424 |
1425 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
1426 |
1427 | 15
1428 |
1429 | Lemma 4.5. The identity map
1430 |
1431 | I : (X, d∗∞) → L2(Rnx × Rt) defined by (v, u, q) → (v, u, q)
1432 | is a Baire-1 map and therefore the set of points of continuity is residual in (X, d∗∞).
1433 |
1434 | Proof. Let φr(x, t) = r−(n+1)φ(rx, rt) be any regular space-time convolution kernel. For each fixed (v, u, q) ∈ X we have
1435 |
1436 | (φr ∗ v, φr ∗ u, φr ∗ q) → (v, u, q) strongly in L2 as r → 0. On the other hand, for each r > 0 and (vk, uk, qk) ∈ X
1437 |
1438 | (vk, uk, qk) ⇀∗ (v, u, q) in L∞ =⇒ φr ∗ (vk, uk, qk) → φr ∗ (v, u, q) in L2. Therefore each map Ir : (X, d∗∞) → L2 defined by
1439 | Ir : (u, v, q) → (φr ∗ v, φr ∗ u, φr ∗ q)
1440 |
1441 | is continuous, and
1442 |
1443 | I (v,
1444 |
1445 | u,
1446 |
1447 | q)
1448 |
1449 | =
1450 |
1451 | lim
1452 | r→0
1453 |
1454 | Ir (v,
1455 |
1456 | u,
1457 |
1458 | q)
1459 |
1460 | for all (v, u, q) ∈ X .
1461 |
1462 | This shows that I : (X, d∗∞) → L2 is a pointwise limit of continuous maps, hence it is a Baire-1 map. Therefore the set of points of continuity of I is
1463 | residual in (X, d∗∞), see [20].
1464 |
1465 | 4.3. Points of continuity of the identity map. The proof of Theorem 4.1 will follow from Lemmas 4.4 and 4.5 once we prove the following
1466 |
1467 | Claim: If (v, u, q) ∈ X is a point of continuity of I, then
1468 |
1469 | |v(x, t)| = 1 for almost every (x, t) ∈ Ω .
1470 |
1471 | (29)
1472 |
1473 | Indeed, if the claim is true, then the set of (v, u, q) ∈ X such that |v| = 1
1474 |
1475 | a.e. is nonempty, yielding solutions of (1). Furthermore, any such (v, u, q)
1476 |
1477 | must be the strong L2 limit of some sequence {(vk, uk, qk)} ⊂ X0. Therefore,
1478 |
1479 | with
1480 |
1481 | pk
1482 |
1483 | =
1484 |
1485 | qk
1486 |
1487 | −
1488 |
1489 | 1 n
1490 |
1491 | |vk
1492 |
1493 | |2,
1494 |
1495 | and
1496 |
1497 | fk = div
1498 |
1499 | vk
1500 |
1501 | ⊗
1502 |
1503 | vk
1504 |
1505 | −
1506 |
1507 | 1 n
1508 |
1509 | |vk
1510 |
1511 | |2I
1512 |
1513 | d
1514 |
1515 | −
1516 |
1517 | uk
1518 |
1519 | ,
1520 |
1521 | we obtain div vk = 0 and
1522 |
1523 | ∂tvk + div vk ⊗ vk + ∇pk = fk.
1524 |
1525 | Moreover, fk → 0 in H−1.
1526 |
1527 | Therefore it remains to prove our claim. Observe that since |v(x, t)| ≤ 1 a.e. (x, t) ∈ Ω, (29) is equivalent to
1528 | v L2(Ω) = |Ω|,
1529 |
1530 | 16
1531 |
1532 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
1533 |
1534 | where |Ω| denotes the (n + 1)-dimensional Lebesgue measure of Ω. To prove the claim we prove the following lemma, from which the claim immediately follows:
1535 |
1536 | Lemma 4.6. There exists a dimensional constant β > 0 with the following
1537 |
1538 | property. Given (v0, u0, q0) ∈ X0 there exists a sequence (vk, uk, qk) ∈ X0
1539 |
1540 | such that
1541 |
1542 | vk
1543 |
1544 | 2 L2 (Ω)
1545 |
1546 | ≥
1547 |
1548 | v0
1549 |
1550 | 2 L2 (Ω)
1551 |
1552 | +
1553 |
1554 | β
1555 |
1556 | |Ω| −
1557 |
1558 | v0
1559 |
1560 | 2 L2 (Ω)
1561 |
1562 | 2
1563 | ,
1564 |
1565 | (30)
1566 |
1567 | and (vk, uk, qk) ⇀∗ (v0, u0, q0) in L∞(Ω).
1568 |
1569 | Indeed, assume for a moment that (v, u, q) is a point of continuity of I. Fix a sequence {(vk, uk, qk} ⊂ X0 converges weakly∗ to (v, u, q). Using
1570 | Lemma 4.6 and a standard diagonal argument, we can produce a second sequences (v˜k, u˜k, q˜k) which converges weakly∗ to (v, u, q) and such that
1571 |
1572 | lim inf
1573 | k→∞
1574 |
1575 | v˜k
1576 |
1577 | 2 2
1578 |
1579 | ≥ lim inf
1580 | k→∞
1581 |
1582 | vk
1583 |
1584 | 2 2
1585 |
1586 | +
1587 |
1588 | β
1589 |
1590 | |Ω| −
1591 |
1592 | vk
1593 |
1594 | 2 2
1595 |
1596 | 2
1597 |
1598 | .
1599 |
1600 | (31)
1601 |
1602 | Since I is continuous at (v, u, q), both vk and v˜k converge strongly to v.
1603 |
1604 | Therefore
1605 |
1606 | v
1607 |
1608 | 2 2
1609 |
1610 | ≥
1611 |
1612 | v
1613 |
1614 | 2 2
1615 |
1616 | +
1617 |
1618 | β
1619 |
1620 | |Ω| −
1621 |
1622 | v
1623 |
1624 | 2 2
1625 |
1626 | 2.
1627 |
1628 | (32)
1629 |
1630 | Therefore,
1631 |
1632 | v
1633 |
1634 | 2 2
1635 |
1636 | = |Ω|.
1637 |
1638 | On the other
1639 |
1640 | hand, since v = 0 a.e.
1641 |
1642 | outside Ω and
1643 |
1644 | |v| ≤ 1 a.e. on Ω, this implies (29).
1645 |
1646 | Proof of Lemma 4.6. Step 1. Let (v0, u0, q0) ∈ X0. By Lemma 4.3 for any (x, t) ∈ Ω there exists a direction
1647 | v¯(x, t), u¯(x, t) ∈ Rn × S0n
1648 | such that the line segment with endpoints
1649 |
1650 | v0(x, t), u0(x, t), q0(x, t) ± v¯(x, t), u¯(x, t), 0
1651 | is contained in U, and |v¯(x, t)| ≥ C(1 − |v0(x, t)|2).
1652 | Moreover, since (v0, u0, q0) is uniformly continuous, there exists ε > 0 such that for any (x, t), (x0, t0) ∈ Ω with |x−x0|+|t−t0| < ε, the ε-neighbourhood of the line segment with endpoints
1653 |
1654 | v0(x, t), u0(x, t), q0(x, t) ± v¯(x0, t0), u¯(x0, t0), 0 is also contained in U.
1655 |
1656 | Step 2. Fix (x0, t0) ∈ Ω for the moment. Use Proposition 2.2 with
1657 |
1658 | a = (v¯(x0, t0), u¯(x0, t0), 0) ∈ Λ
1659 |
1660 | and ε > 0 to obtain a smooth solution (v, u, q) of (8) with the properties stated in the Proposition, and for any r < ε let
1661 |
1662 | (vr, ur, qr)(x, t) = (v, u, q)
1663 |
1664 | x
1665 |
1666 | − r
1667 |
1668 | x0
1669 |
1670 | ,
1671 |
1672 | t
1673 |
1674 | − r
1675 |
1676 | t0
1677 |
1678 | .
1679 |
1680 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
1681 |
1682 | 17
1683 |
1684 | Then (vr, ur, qr) is also a smooth solution of (8), with the properties • the support of (vr, ur, qr) is contained in Br(x0, t0) ⊂ Rnx × Rt, • the image of (vr, ur, qr) is contained in the ε–neighborhood of the line-segment with endpoints ±(v¯(x, t), u¯(x, t), 0), • and
1685 | |vr(x, t)| dx dt ≥ α|v¯(x0, t0)||Br(x0, r0)|.
1686 |
1687 | In particular, for any r < ε we have (v0, u0, q0) + (vr, ur, qr) ∈ X0.
1688 | Step 3. Next, observe that since v0 is uniformly continuous, there exists r0 > 0 such that for any r < r0 there exists a finite family of pairwise disjoint balls Brj (xj, tj) ⊂ Ω with rj < r such that
1689 |
1690 | (1 − |v0(x, t)|2)dxdt ≤ 2 (1 − |v0(xj, tj)|2)|Br(xj, tj)| (33)
1691 |
1692 | Ω
1693 |
1694 | j
1695 |
1696 | Fix
1697 |
1698 | k
1699 |
1700 | ∈
1701 |
1702 | N with
1703 |
1704 | 1 k
1705 |
1706 | <
1707 |
1708 | min{r0, ε}
1709 |
1710 | and
1711 |
1712 | choose a
1713 |
1714 | finite family
1715 |
1716 | of
1717 |
1718 | pair-
1719 |
1720 | wise
1721 |
1722 | disjoint
1723 |
1724 | balls
1725 |
1726 | Brk,j (xk,j , tk,j )
1727 |
1728 | ⊂
1729 |
1730 | Ω
1731 |
1732 | with
1733 |
1734 | radii
1735 |
1736 | rk,j
1737 |
1738 | <
1739 |
1740 | 1 k
1741 |
1742 | such
1743 |
1744 | that
1745 |
1746 | (33)
1747 |
1748 | holds. In each ball Brk,j (xk,j, tk,j) we apply the construction above to ob-
1749 |
1750 | tain (vk,j, uk,j, qk,j), and in particular we then have
1751 |
1752 | (vk, uk, qk) := (v0, u0, q0) + (vk,j, uk,j, qk,j) ∈ X0,
1753 | j
1754 | and
1755 |
1756 | |vk(x, t) − v0(x, t)|dxdt =
1757 | j
1758 |
1759 | |vk,j(x, t)|dxdt
1760 |
1761 | ≥ α |v¯(xk,j, tk,j)||Brk,j (xk,j, tk,j)|
1762 | j
1763 |
1764 | ≥ Cα (1 − |v0(xk,j, tk,j)|2)|Brk,j (xk,j, tk,j)|
1765 | j
1766 |
1767 | ≥
1768 |
1769 | 1Cα 2
1770 |
1771 | (1 − |v0(x, t)|2)dxdt.
1772 | Ω
1773 |
1774 | (34)
1775 |
1776 | Finally observe that by letting k → ∞, the above construction yields a sequence (vk, uk, qk) ∈ X0 such that
1777 |
1778 | (vk, uk, qk) ⇀∗ (v0, u0, q0).
1779 |
1780 | (35)
1781 |
1782 | Hence,
1783 |
1784 | lim inf
1785 | k→∞
1786 |
1787 | vk L2(Ω)
1788 |
1789 | =
1790 |
1791 | v0
1792 |
1793 | 2 2
1794 |
1795 | +
1796 |
1797 | lim inf
1798 | k→∞
1799 |
1800 | v0, (vk − v0) 2 +
1801 |
1802 | vk − v0
1803 |
1804 | 2 2
1805 |
1806 | (3=5)
1807 |
1808 | |v0
1809 |
1810 | 2 2
1811 |
1812 | +
1813 |
1814 | lim inf
1815 | k→∞
1816 |
1817 | vk − v0
1818 |
1819 | 2 2
1820 |
1821 | ≥
1822 |
1823 | v0
1824 |
1825 | 2 2
1826 |
1827 | +
1828 |
1829 | |Ω|
1830 |
1831 | lim inf
1832 | k→∞
1833 |
1834 | vk − v0 L1(Ω) 2
1835 |
1836 | (36)
1837 |
1838 | 18
1839 |
1840 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
1841 |
1842 | Combining (34) and (36) we get
1843 |
1844 | lim inf
1845 | k→∞
1846 |
1847 | vk
1848 |
1849 | L2 (Ω)
1850 |
1851 | ≥
1852 |
1853 | v0
1854 |
1855 | 2 L2 (Ω)
1856 |
1857 | +
1858 |
1859 | |Ω|C 2 α2 4
1860 |
1861 | which
1862 |
1863 | gives
1864 |
1865 | (30)
1866 |
1867 | with
1868 |
1869 | β
1870 |
1871 | =
1872 |
1873 | 1 4
1874 |
1875 | |Ω|C
1876 |
1877 | 2α2
1878 |
1879 | .
1880 |
1881 | |Ω| −
1882 |
1883 | v0
1884 |
1885 | 2 L2 (Ω)
1886 |
1887 | 2
1888 | ,
1889 |
1890 | 5. A proof of Theorem 4.1 using convex integration
1891 | In this section we provide an alternative, more direct proof for Theorem 4.1, following the method of convex integration as presented for example in [17].
1892 | In fact the two approaches (i.e. Baire category methods and convex integration) can be unified to a large extent. For a discussion comparing the two approaches we refer to the end of Section 3.3 in [14], see also the paper [24] for a different point of view. Nevertheless, in order to get a feeling for the type of solution that Theorem 4.1 produces, it helps to see the direct construction of the convex integration method.
1893 | We will freely refer to the notation of the previous sections. In particular the proof relies on Lemmas 4.2, 4.3, 4.4 and 4.6. These results enable us to construct an approximating sequence, as explained briefly at the beginning of Section 4, by adding (almost-)plane-waves on top of each other. It is only the limiting step that is more explicit in this approach. The following argument is essentially from Section 3.3 in [17].
1894 |
1895 | Alternative proof of Theorem 4.1. Using Lemma 4.6, we construct inductively a sequence (vk, uk, qk) ∈ X0 and a sequence of numbers ηk > 0 as follows. Let ρε be a standard mollifying kernel in Rn+1 = Rnx × Rt and set (v1, u1, q1) ≡ 0 in Rnx × Rt.
1896 |
1897 | Having obtained zj := (vj, uj, qj) for j ≤ k and η1, . . . , ηk−1 we choose
1898 |
1899 | ηk < 2−k
1900 |
1901 | (37)
1902 |
1903 | in such a way that
1904 |
1905 | zk − zk ∗ ρηk L2(Ω) < 2−k.
1906 |
1907 | (38)
1908 |
1909 | Then we apply Lemma 4.6 to obtain zk+1 = (vk+1, uk+1, qk+1) ∈ X0 such
1910 |
1911 | that
1912 |
1913 | vk+1
1914 |
1915 | 2 L2 (Ω)
1916 |
1917 | ≥
1918 |
1919 | vk
1920 |
1921 | 2 L2 (Ω)
1922 |
1923 | +
1924 |
1925 | β
1926 |
1927 | |Ω| −
1928 |
1929 | vk
1930 |
1931 | 2 L2 (Ω)
1932 |
1933 | 2
1934 | ,
1935 |
1936 | (39)
1937 |
1938 | and
1939 |
1940 | (zk+1 − zk) ∗ ρηj L2(Ω) < 2−k for all j ≤ k.
1941 |
1942 | (40)
1943 |
1944 | The sequence {zk} is bounded in L∞(Rnx × Rt), therefore by passing to a suitable subsequence we may assume without loss of generality that
1945 | zk ⇀∗ z in L∞(Rnx × Rt)
1946 |
1947 | THE EULER EQUATIONS AS A DIFFERENTIAL INCLUSION
1948 |
1949 | 19
1950 |
1951 | for some z = (v, u, q) ∈ X, and that the sequence {zk} and the corresponding sequence {ηk} satisfies the properties (37),(38),(39) and (40). Then for every k∈N
1952 |
1953 | ∞
1954 |
1955 | zk ∗ ρηk − z ∗ ρηk L2(Ω) ≤
1956 |
1957 | zk+j ∗ ρηk − zk+j+1 ∗ ρηk L2(Ω)
1958 |
1959 | j=0
1960 |
1961 | ∞
1962 | ≤ 2−(k+j) ≤ 2−k+1,
1963 |
1964 | j=0
1965 |
1966 | and since zk − z L2(Ω) ≤ zk − zk ∗ ρηk L2(Ω) + zk ∗ ρηk − z ∗ ρηk L2(Ω) + z ∗ ρηk − z L2(Ω),
1967 | we deduce that vk → v strongly in L2(Ω). Therefore, passing into the limit in (39) we conclude
1968 |
1969 | v
1970 |
1971 | 2 L2 (Ω)
1972 |
1973 | ≥
1974 |
1975 | v
1976 |
1977 | 2 L2 (Ω)
1978 |
1979 | +
1980 |
1981 | β
1982 |
1983 | |Ω| −
1984 |
1985 | v
1986 |
1987 | 2 L2 (Ω)
1988 |
1989 | 2
1990 |
1991 | (41)
1992 |
1993 | and hence
1994 |
1995 | v
1996 |
1997 | 2 2
1998 |
1999 | =
2000 |
2001 | |Ω|.
2002 |
2003 | Since v vanishes outside Ω and |v| ≤ 1 in Ω, we
2004 |
2005 | conclude that |v| = 1Ω. Since (v, u, q) ∈ X, we also have that (v, u)(x, t) ∈
2006 |
2007 | Kco for a.e. (x, t) ∈ Ω. From this we deduce that (v, u)(x, t) ∈ K for a.e.
2008 |
2009 | (x, t) ∈ Ω, thus concluding the proof.
2010 |
2011 | References
2012 | [1] Bressan, A., and Flores, F. On total differential inclusions. Rend. Sem. Mat. Univ. Padova 92 (1994), 9–16.
2013 | [2] Cellina, A. On the differential inclusion x′ ∈ [−1, +1]. Atti Accad. Naz. Lincei Rend. Cl. Sci. Fis. Mat. Natur. (8) 69, 1-2 (1980), 1–6 (1981).
2014 | [3] Chorin, A. J. Vorticity and turbulence, vol. 103 of Applied Mathematical Sciences. Springer-Verlag, New York, 1994.
2015 | [4] Constantin, P., E, W., and Titi, E. S. Onsager’s conjecture on the energy conservation for solutions of Euler’s equation. Comm. Math. Phys. 165, 1 (1994), 207–209.
2016 | [5] Dacorogna, B., and Marcellini, P. General existence theorems for HamiltonJacobi equations in the scalar and vectorial cases. Acta Math. 178 (1997), 1–37.
2017 | [6] Dafermos, C. M. Hyperbolic conservation laws in continuum physics, vol. 325 of Grundlehren der Mathematischen Wissenschaften [Fundamental Principles of Mathematical Sciences]. Springer-Verlag, Berlin, 2000.
2018 | [7] DiPerna, R. J. Compensated compactness and general systems of conservation laws. Trans. Amer. Math. Soc. 292, 2 (1985), 383–420.
2019 | [8] DiPerna, R. J., and Majda, A. J. Concentrations in regularizations for 2-D incompressible flow. Comm. Pure Appl. Math. 40, 3 (1987), 301–345.
2020 | [9] Duchon, J., and Robert, R. Inertial energy dissipation for weak solutions of incompressible Euler and Navier-Stokes equations Nonlinearity, 13 (2000), 249–255.
2021 | [10] Eyink, G. L. Energy dissipation without viscosity in ideal hydrodynamics. I. Fourier analysis and local energy transfer. Phys. D 78, 3-4 (1994), 222–240.
2022 | [11] Frisch, U. Turbulence. Cambridge University Press, Cambridge, 1995. The legacy of A. N. Kolmogorov.
2023 | [12] Gromov, M. Partial differential relations, vol. 9 of Ergebnisse der Mathematik und ihrer Grenzgebiete (3). Springer-Verlag, Berlin, 1986.
2024 |
2025 | 20
2026 |
2027 | CAMILLO DE LELLIS AND LA´ SZLO´ SZE´ KELYHIDI JR.
2028 |
2029 | [13] Kirchheim, B. Deformations with finitely many gradients and stability of quasiconvex hulls. C. R. Acad. Sci. Paris S´er. I Math. 332, 3 (2001), 289–294.
2030 | [14] Kirchheim, B. Rigidity and Geometry of microstructures. Habilitation thesis, University of Leipzig, 2003.
2031 | [15] Kirchheim, B., Mu¨ller, S., and Sˇvera´k, V. Studying nonlinear PDE by geometry in matrix space. In Geometric analysis and Nonlinear partial differential equations, S. Hildebrandt and H. Karcher, Eds. Springer-Verlag, 2003, pp. 347–395.
2032 | [16] Majda, A. J., and Bertozzi, A. L. Vorticity and incompressible flow, vol. 27 of Cambridge Texts in Applied Mathematics. Cambridge University Press, Cambridge, 2002.
2033 | [17] Mu¨ller, S., and Sˇvera´k, V. Convex integration for Lipschitz mappings and counterexamples to regularity. Ann. of Math. (2) 157, 3 (2003), 715–742.
2034 | [18] Mu¨ller, S., and Sychev, M. Optimal existence theorems for nonhomogeneous differential inclusions. J. Funct. Anal. 181, 2 (2001), 447–475.
2035 | [19] Onsager, L. Statistical hydrodynamics. Nuovo Cimento (9) 6, Supplemento, 2(Convegno Internazionale di Meccanica Statistica) (1949), 279–287.
2036 | [20] Oxtoby, J. C. Measure and category, second ed., vol. 2 of Graduate Texts in Mathematics. Springer-Verlag, New York, 1980. A survey of the analogies between topological and measure spaces.
2037 | [21] Scheffer, V. An inviscid flow with compact support in space-time. J. Geom. Anal. 3, 4 (1993), 343–401.
2038 | [22] Shnirelman, A. On the nonuniqueness of weak solution of the Euler equation. Comm. Pure Appl. Math. 50, 12 (1997), 1261–1286.
2039 | [23] Shnirelman, A. Weak solutions with decreasing energy of incompressible Euler equations. Comm. Math. Phys. 210, 3 (2000), 541–603.
2040 | [24] Sychev, M. A. A few remarks on differential inclusions. Proc. Roy. Soc. Edinburgh Sect. A, 3 (2006), 649-668.
2041 | [25] Tao, T. Nonlinear dispersive equations, vol. 106 of CBMS Regional Conference Series in Mathematics. Published for the Conference Board of the Mathematical Sciences, Washington, DC, 2006. Local and global analysis.
2042 | [26] Tartar, L. Compensated compactness and applications to partial differential equations. In Nonlinear analysis and mechanics: Heriot-Watt Symposium, Vol. IV, vol. 39 of Res. Notes in Math. Pitman, Boston, Mass., 1979, pp. 136–212.
2043 | [27] Tartar, L. The compensated compactness method applied to systems of conservation laws. In Systems of nonlinear partial differential equations (Oxford, 1982), vol. 111 of NATO Adv. Sci. Inst. Ser. C Math. Phys. Sci. Reidel, Dordrecht, 1983, pp. 263–285.
2044 | [28] Temam, R. Navier-Stokes equations, third ed., vol. 2 of Studies in Mathematics and its Applications. North-Holland Publishing Co., Amsterdam, 1984. Theory and numerical analysis, With an appendix by F. Thomasset.
2045 | Institut fu¨r Mathematik, Universita¨t Zu¨rich, CH-8057 Zu¨rich E-mail address: camillo.delellis@math.unizh.ch
2046 | Departement Mathematik, ETH Zu¨rich, CH-8092 Zu¨rich E-mail address: szekelyh@math.ethz.ch
2047 |
2048 |
--------------------------------------------------------------------------------
/tests/resources/sql/storage/PIMHYJGK/.zotero-ft-info:
--------------------------------------------------------------------------------
1 | Title:
2 | Subject:
3 | Keywords:
4 | Author:
5 | Creator: LaTeX with hyperref package
6 | Producer: dvips + GPL Ghostscript SVN PRE-RELEASE 8.62
7 | CreationDate: Sat Feb 2 07:26:26 2008
8 | ModDate: Sat Feb 2 07:26:26 2008
9 | Tagged: no
10 | Form: none
11 | Pages: 20
12 | Encrypted: no
13 | Page size: 612 x 792 pts (letter) (rotated 0 degrees)
14 | File size: 277364 bytes
15 | Optimized: no
16 | PDF version: 1.2
17 |
--------------------------------------------------------------------------------
/tests/resources/sql/storage/PIMHYJGK/.zotero-pdf-state:
--------------------------------------------------------------------------------
1 | {"pageIndex":0,"scale":"page-width","top":792,"left":-6,"scrollMode":0,"spreadMode":0}
--------------------------------------------------------------------------------
/tests/resources/sql/storage/PIMHYJGK/De Lellis and Székelyhidi - 2009 - The Euler equations as a differential inclusion.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/sql/storage/PIMHYJGK/De Lellis and Székelyhidi - 2009 - The Euler equations as a differential inclusion.pdf
--------------------------------------------------------------------------------
/tests/resources/sql/storage/WN7WJBGS/.zotero-ft-info:
--------------------------------------------------------------------------------
1 | Title: ()
2 | Subject: ()
3 | Keywords: ()
4 | Author: ()
5 | Creator: LaTeX with hyperref package
6 | Producer: dvips + GPL Ghostscript GIT PRERELEASE 9.08
7 | CreationDate: Wed Nov 20 21:03:39 2013
8 | ModDate: Wed Nov 20 21:03:39 2013
9 | Tagged: no
10 | Form: none
11 | Pages: 28
12 | Encrypted: no
13 | Page size: 595 x 842 pts (A4) (rotated 0 degrees)
14 | File size: 351391 bytes
15 | Optimized: no
16 | PDF version: 1.4
17 |
--------------------------------------------------------------------------------
/tests/resources/sql/storage/WN7WJBGS/.zotero-pdf-state:
--------------------------------------------------------------------------------
1 | {"pageIndex":0,"scale":"page-width","top":845,"left":-6,"scrollMode":0,"spreadMode":0}
--------------------------------------------------------------------------------
/tests/resources/sql/storage/WN7WJBGS/Svärd and Nordström - 2014 - Review of summation-by-parts schemes for initial–b.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/sql/storage/WN7WJBGS/Svärd and Nordström - 2014 - Review of summation-by-parts schemes for initial–b.pdf
--------------------------------------------------------------------------------
/tests/resources/sql/zotero.sqlite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papis/papis-zotero/b4f8296202630ba11929ec793da2c3e5dbcfc879/tests/resources/sql/zotero.sqlite
--------------------------------------------------------------------------------
/tests/resources/sql_out.yaml:
--------------------------------------------------------------------------------
1 | author: Svärd, Magnus and Nordström, Jan
2 | author_list:
3 | - family: Svärd
4 | given: Magnus
5 | - family: Nordström
6 | given: Jan
7 | doi: 10.1016/j.jcp.2014.02.031
8 | files:
9 | - WN7WJBGS.pdf
10 | issn: 00219991
11 | journal: Journal of Computational Physics
12 | journalAbbreviation: Journal of Computational Physics
13 | language: en
14 | libraryCatalog: DOI.org (Crossref)
15 | month: 7
16 | pages: 17-38
17 | ref: ReviewOfSummaSvard2014
18 | time-added: 2023-02-26-09:05:00
19 | title: Review of summation-by-parts schemes for initial–boundary-value problems
20 | type: article
21 | url: https://linkinghub.elsevier.com/retrieve/pii/S002199911400151X
22 | volume: '268'
23 | year: 2014
24 |
--------------------------------------------------------------------------------
/tests/test_bibtex.py:
--------------------------------------------------------------------------------
1 | import os
2 | import yaml
3 | import pytest
4 |
5 | import papis.id
6 | import papis.yaml
7 | import papis.database
8 | import papis.document
9 | import papis_zotero.bibtex
10 | from papis.testing import TemporaryLibrary
11 |
12 |
13 | @pytest.mark.skipif(os.name == "nt", reason="encoding is incorrect on windows")
14 | @pytest.mark.library_setup(populate=False)
15 | def test_simple(tmp_library: TemporaryLibrary) -> None:
16 | bibpath = os.path.join(os.path.dirname(__file__),
17 | "resources", "bibtex", "zotero-library.bib")
18 | papis_zotero.bibtex.add_from_bibtex(bibpath, tmp_library.libname, link=False)
19 |
20 | db = papis.database.get()
21 | db.clear()
22 | db.initialize()
23 |
24 | doc, = db.query_dict({"author": "Magnus"})
25 | with open(doc.get_info_file(), encoding="utf-8") as fd:
26 | data = yaml.load(
27 | fd, Loader=papis.yaml.Loader) # type: ignore[attr-defined]
28 | del data[papis.id.key_name()]
29 |
30 | info_name = os.path.join(os.path.dirname(__file__), "resources", "bibtex_out.yaml")
31 | with open(info_name, encoding="utf-8") as fd:
32 | expected_data = yaml.load(
33 | fd, Loader=papis.yaml.Loader) # type: ignore[attr-defined]
34 |
35 | assert data == expected_data
36 |
--------------------------------------------------------------------------------
/tests/test_sql.py:
--------------------------------------------------------------------------------
1 | import os
2 | import glob
3 | import yaml
4 | import pytest
5 |
6 | import papis.yaml
7 | import papis.document
8 | import papis_zotero.sql
9 | from papis.testing import TemporaryLibrary
10 |
11 |
12 | @pytest.mark.skipif(os.name == "nt", reason="encoding is incorrect on windows")
13 | @pytest.mark.library_setup(populate=False)
14 | def test_simple(tmp_library: TemporaryLibrary) -> None:
15 | sqlpath = os.path.join(os.path.dirname(__file__), "resources", "sql")
16 | papis.config.set("add-folder-name", "{doc[author]}")
17 | papis_zotero.sql.add_from_sql(sqlpath)
18 |
19 | folders = os.listdir(tmp_library.libdir)
20 | assert len(folders) == 5
21 | assert len(glob.glob(tmp_library.libdir + "/**/*.pdf")) == 4
22 |
23 | doc = papis.document.from_folder(
24 | os.path.join(
25 | tmp_library.libdir,
26 | "svard-magnus-and-nordstrom-jan"
27 | )
28 | )
29 |
30 | info_name = os.path.join(os.path.dirname(__file__), "resources", "sql_out.yaml")
31 | with open(info_name, encoding="utf-8") as fd:
32 | data = yaml.load(fd, Loader=papis.yaml.Loader) # type: ignore[attr-defined]
33 | expected_doc = papis.document.from_data(data)
34 |
35 | assert expected_doc["author"] == doc["author"]
36 |
37 | # FIXME: currently fails on windows
38 | # assert doc.get_files()
39 |
--------------------------------------------------------------------------------
/tools/update-pypi.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env bash
2 | set -ex
3 |
4 | DIST_DIR=dist
5 |
6 |
7 | rm -rf distenv
8 | virtualenv -p python3 distenv
9 | source ./distenv/bin/activate
10 | pip install .
11 | pip install .[develop]
12 |
13 | rm -rf ${DIST_DIR}
14 | python3 setup.py sdist
15 |
16 | pip install twine
17 | read -p "Do you want to push? (y/N)" -n 1 -r
18 | echo
19 | if [[ $REPLY =~ ^[Yy]$ ]]; then
20 | twine upload ${DIST_DIR}/*.tar.gz
21 | fi
22 | REPLY= # unset REPLY after using it
23 |
--------------------------------------------------------------------------------